changeset fbd06865965b in tryton:5.8 details: https://hg.tryton.org/tryton?cmd=changeset;node=fbd06865965b description: Set loaded fields first after O2M on_change calls
issue9930 review302811002 (grafted from 65002d9965d4e90f160baa20dc4edcf16c32a6eb) diffstat: tryton/gui/window/view_form/model/field.py | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diffs (38 lines): diff -r bf5ba8d1bcda -r fbd06865965b tryton/gui/window/view_form/model/field.py --- a/tryton/gui/window/view_form/model/field.py Wed Feb 03 19:34:15 2021 +0100 +++ b/tryton/gui/window/view_form/model/field.py Thu Feb 04 18:05:18 2021 +0100 @@ -763,12 +763,12 @@ for f in v if f not in fields and f != 'id' and '.' not in f) if field_names: try: - fields = RPCExecute('model', self.attrs['relation'], + new_fields = RPCExecute('model', self.attrs['relation'], 'fields_get', list(field_names), context=context) except RPCException: return else: - fields = {} + new_fields = {} group = record.value[self.name] if value and value.get('delete'): @@ -787,7 +787,18 @@ force_remove=False) if value and (value.get('add') or value.get('update', [])): - record.value[self.name].add_fields(fields) + # First set already added fields to prevent triggering a + # second on_change call + for vals in value.get('update', []): + if 'id' not in vals: + continue + record2 = group.get(vals['id']) + if record2 is not None: + vals_to_set = { + k: v for k, v in vals.items() if k not in new_fields} + record2.set_on_change(vals_to_set) + + record.value[self.name].add_fields(new_fields) for index, vals in value.get('add', []): new_record = None id_ = vals.pop('id', None)