Do not restore values for created records when exception is raised when saving
Once a record has been created, the id is modified which change its hash value such that it can not be found anymore. But as the creation succeeded (and only the write part has failed) we can just restore the values to None. Closes #14093 (grafted from a56b25f536568b808bc4c57b6cee03408eaf06f2) --HG-- branch : 7.0
This commit is contained in:
1 parent
28a069fae3
commit
f07f5f0792
1 file changed
+2
-2
@@ -1997,8 +1997,8 @@ class ModelStorage(Model):
|
||||
cls.write(*sum(
|
||||
(([r], save_values[r]) for r in to_write), ()))
|
||||
except Exception:
|
||||
for record in to_create + to_write:
|
||||
record._values = values[record]
|
||||
for record in chain(to_create, to_write):
|
||||
record._values = values.get(record)
|
||||
raise
|
||||
for record in to_create + to_write:
|
||||
record._init_values = None
|
||||
|
||||
Reference in new issue
Block a user