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
This commit is contained in:
Cédric Krier committed 2014-02-24 19:20:47 +01:00
1 parent 2680d1b746
commit 66a5f7b6f4
1 file changed
+3
+3
View File
@@ -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: