From a0dbb919f694b91ecce0b19abccfab03fc78f2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Sep 2018 22:16:58 +0200 Subject: [PATCH] Link record added via on_change to the xxx2many group The new record must be link to the group otherwise it will not trigger on_change call for the parent. issue7708 review52491002 --- proteus/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proteus/__init__.py b/proteus/__init__.py index 0e442cd024..ce5c9aa8a7 100644 --- a/proteus/__init__.py +++ b/proteus/__init__.py @@ -1017,18 +1017,19 @@ class Model(object): getattr(self, field).remove(record, _changed=False) if value and (value.get('add') or value.get('update')): for index, vals in value.get('add', []): + group = getattr(self, field) Relation = Model.get( self._fields[field]['relation'], self._config) config = Relation._config with config.reset_context(), \ config.set_context(self._context): - record = Relation(_default=False) + record = Relation(_group=group, _default=False) record._set_on_change(vals) # append without signal if index == -1: - list.append(getattr(self, field), record) + list.append(group, record) else: - list.insert(getattr(self, field), index, record) + list.insert(group, index, record) for vals in value.get('update', []): if 'id' not in vals: continue