diff --git a/tryton/gui/window/view_form/model/field.py b/tryton/gui/window/view_form/model/field.py index 4258261f5e..cb39719467 100644 --- a/tryton/gui/window/view_form/model/field.py +++ b/tryton/gui/window/view_form/model/field.py @@ -70,6 +70,10 @@ class CharField(object): def get(self, model, check_load=True, readonly=True, modified=False): return model.value.get(self.name, False) or False + def get_eval(self, model, check_load=True): + return self.get(model, check_load=check_load, readonly=True, + modified=False) + def set_client(self, model, value, test_state=True, force_change=False): internal = model.value.get(self.name, False) self.set(model, value, test_state) @@ -278,6 +282,10 @@ class M2MField(CharField): def get(self, model, check_load=True, readonly=True, modified=False): return [('set', model.value[self.name] or [])] + def get_eval(self, model, check_load=True): + return self.get(model, check_load=check_load, readonly=True, + modified=False)[0][1] + def get_client(self, model): return model.value[self.name] or [] @@ -346,6 +354,14 @@ class O2MField(CharField): result.append(('delete', model.value[self.name].model_deleted)) return result + def get_eval(self, model, check_load=True): + result = [] + if not model.value[self.name]: + return [] + for model2 in model.value[self.name].models: + result.append(model2.get_eval(check_load=check_load)) + return result + def set(self, model, value, test_state=False, modified=False): from group import ModelRecordGroup mod = ModelRecordGroup(self.attrs['relation'], {}, model.window, diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 6b70342297..93db1d8e72 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -285,7 +285,7 @@ class ModelRecordGroup(SignalEvent): return None return self.models[self.current_idx] - def remove(self, model, remove=False): + def remove(self, model, remove=False, modified=True): idx = self.models.index(model) if self.models[idx].id: if remove: @@ -294,7 +294,10 @@ class ModelRecordGroup(SignalEvent): self.model_deleted.append(self.models[idx].id) if model.parent: model.parent.modified = True + if modified: + model.modified = True self.models.remove(self.models[idx]) + model.signal('record-changed', model.parent) def add_fields_custom(self, fields, models): to_add = [] diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index bd8b05d8c1..4297e81a35 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -123,6 +123,15 @@ class ModelRecord(SignalEvent): value['id'] = self.id return value + def get_eval(self, check_load=True): + if check_load: + self._check_load() + value = {} + for name, mfield in self.mgroup.mfields.items(): + value[name] = mfield.get_eval(self, check_load=check_load) + value['id'] = self.id + return value + def cancel(self): self._loaded = False self.reload() @@ -271,7 +280,7 @@ class ModelRecord(SignalEvent): self._check_load() ctx = rpc.CONTEXT.copy() for name, mfield in self.mgroup.mfields.items(): - ctx[name] = mfield.get(self, check_load=check_load) + ctx[name] = mfield.get_eval(self, check_load=check_load) ctx['current_date'] = datetime.datetime.today() ctx['time'] = time