diff options
| author | Raphael Collet <rco@odoo.com> | 2020-05-05 08:54:53 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-05-06 19:25:17 +0000 |
| commit | eb08e2c22896334fc26aedb353a310421e42b89b (patch) | |
| tree | ea10f34605c89bb507a0adc324335cb3090ce9df /odoo/fields.py | |
| parent | 864e1ed61d3a19b4ebb19ba15c625c5d3079e3ba (diff) | |
[FIX] core: unexpected cache invalidation when updating one2many
When setting a many2one field, the corresponding one2many fields are
updated in cache. When such a one2many field has a domain, the
evaluation of the domain may require to fetch some fields from the
database. If the `towrite` cache has not been updated yet, the many2one
field is overridden by the database value.
Fix by setting the `towrite` cache before updating inverse fields.
closes odoo/odoo#50788
X-original-commit: c1ebfe05a66cfebc7ced36e25db5f6ff4bfb2d46
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 41e50c722f6..23eb491b0bc 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -2600,9 +2600,6 @@ class Many2one(_Relational): # update the cache of self cache.update(records, self, [cache_value] * len(records)) - # update the cache of one2many fields of new corecord - self._update_inverses(records, cache_value) - # update towrite if self.store: towrite = records.env.all.towrite[self.model_name] @@ -2610,6 +2607,9 @@ class Many2one(_Relational): # cache_value is already in database format towrite[record.id][self.name] = cache_value + # update the cache of one2many fields of new corecord + self._update_inverses(records, cache_value) + return records def _remove_inverses(self, records, value): |
