From 66a5f7b6f4afd3a9358e95ef36ccc8fa7f02b344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 24 Feb 2014 19:20:47 +0100 Subject: [PATCH] When saving record don't store target link for one2many to create When saving an instance if the relation field of a one2many item is set, it should not try to save it as it will be replaced by the current record. And in the worst case, the target set could not be valid and so it prevents to store the instance which doesn't need of this target. issue3501 review3601003 --- trytond/model/modelstorage.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py index 2126daf08b..1bd687b782 100644 --- a/trytond/model/modelstorage.py +++ b/trytond/model/modelstorage.py @@ -1382,6 +1382,9 @@ class ModelStorage(Model): to_write = [] for target in targets: if target.id < 0: + if field._type == 'one2many': + # Don't store old target link + setattr(target, field.field, None) to_create.append(target._save_values) else: if target.id in to_remove: