From 90b6334aca352fadae31d333b3b84685f3db2c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Voet=20=28ryv=29?= Date: Thu, 26 Jan 2023 12:41:32 +0000 Subject: [PATCH] [REM] core: simplify `_update` of `_RelationalMulti` The `_update` of `_RelationalMulti` return a bool but the others `_update` methods doesn't return anything. It is actually not used. Also, the `_update` is always called with a recordset as `value`, then the first part of the method is useless. Part-of: odoo/odoo#111108 --- odoo/fields.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/odoo/fields.py b/odoo/fields.py index f501c03ed42..d35d03d0e63 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -4033,32 +4033,15 @@ class _RelationalMulti(_Relational): # convert_to_record(), depending on the context. def _update(self, records, value): - """ Update the cached value of ``self`` for ``records`` with ``value``, - and return whether everything is in cache. - """ - if not isinstance(records, BaseModel): - # the inverse of self is a non-relational field; `value` is a - # corecord that refers to `records` by an integer field - model = value.env[self.model_name] - domain = self.domain(model) if callable(self.domain) else self.domain - if not value.filtered_domain(domain): - return - records = model.browse(records) - - result = True - + """ Update the cached value of ``self`` for ``records`` with ``value``. """ if value: cache = records.env.cache for record in records: if cache.contains(record, self): val = self.convert_to_cache(record[self.name] | value, record, validate=False) cache.set(record, self, val) - else: - result = False records.modified([self.name]) - return result - def convert_to_cache(self, value, record, validate=True): # cache format: tuple(ids) if isinstance(value, BaseModel):