From 396032dd3c1d80ad1fc02feede0b1a419020fa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Tue, 17 May 2011 15:21:04 +0200 Subject: [PATCH] Use different environment's evaluation according to context of evaluation --- tryton/common/environment.py | 9 +++++++-- tryton/gui/window/view_form/model/record.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tryton/common/environment.py b/tryton/common/environment.py index 296cf9eee6..f644537bfc 100644 --- a/tryton/common/environment.py +++ b/tryton/common/environment.py @@ -4,15 +4,20 @@ class EvalEnvironment(dict): - def __init__(self, parent, check_load): + def __init__(self, parent, check_load, eval_type='eval'): super(EvalEnvironment, self).__init__() self.parent = parent self.check_load = check_load + assert eval_type in ('eval', 'on_change') + self.eval_type = eval_type def __getitem__(self, item): if item == '_parent_' + self.parent.parent_name and self.parent.parent: return EvalEnvironment(self.parent.parent, self.check_load) - return self.parent.get_eval(check_load=self.check_load)[item] + if self.eval_type == 'eval': + return self.parent.get_eval(check_load=self.check_load)[item] + else: + return self.parent._get_on_change_args([item])[item] def __getattr__(self, item): return self.__getitem__(item) diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index 46a9c7b07c..40917df90a 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -434,7 +434,7 @@ class Record(SignalEvent): values[name] = field.get_on_change_value(self, check_load=False) if self.parent and self.parent_name: values['_parent_' + self.parent_name] = \ - common.EvalEnvironment(self.parent, False) + common.EvalEnvironment(self.parent, False, 'on_change') for arg in args: scope = values for i in arg.split('.'):