[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
This commit is contained in:
Rémy Voet (ryv)
2023-02-17 12:07:07 +01:00
parent b998d9a5de
commit 90b6334aca
+1 -18
View File
@@ -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):