summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-06-02 16:25:08 +0200
committerXavier Morel <xmo@odoo.com>2017-06-12 11:04:23 +0200
commitea21c7a8ee5a62bd22d965eb861844ec4e884f75 (patch)
treef5b3e28c69d26238e7aaacdc75f3fc2932f75927 /odoo
parentba1b88db34333d65e0a6abdbc7904a03baaa361b (diff)
[FIX] P3: try to write fields in source order
When adding a Python constraint on a (relational) field which uses an other (relational) field, the order in which the fields are written is also the order in which they are checked, and if a constraint depends on a sibling field this might blow up in P3, here as in as in test_new_api.message.Message (_check_author constraint depends on parent discussion's participants): test_11_stored would commonly fail when creating a discussion with two participants and 3 messages (because the message's authors would be checked before the participants had been associated with the discussion).
Diffstat (limited to 'odoo')
-rw-r--r--odoo/models.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 8a231a756ad..71040650173 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -3423,7 +3423,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
if not key.startswith('default_')}
# call the 'write' method of fields which are not columns
- for name in upd_todo:
+ for name in sorted(upd_todo, key=lambda name: self._fields[name]._sequence):
field = self._fields[name]
field.write(self.with_context(rel_context), vals[name])