[IMP] core: two small optimizations
The method BaseModel.update does not batch records for no reason. This method is used in `_onchange_eval` and in few onchange in Odoo. In _modified_triggers() avoid a useless record union. Part-of: odoo/odoo#79563
This commit is contained in:
committed by
Raphael Collet
parent
28fc83a509
commit
ac44685b71
+3
-4
@@ -5693,9 +5693,8 @@ Fields:
|
||||
|
||||
def update(self, values):
|
||||
""" Update the records in ``self`` with ``values``. """
|
||||
for record in self:
|
||||
for name, value in values.items():
|
||||
record[name] = value
|
||||
for name, value in values.items():
|
||||
self[name] = value
|
||||
|
||||
@api.model
|
||||
def flush(self, fnames=None, records=None):
|
||||
@@ -6160,7 +6159,7 @@ Fields:
|
||||
real_records = self - new_records
|
||||
records = model.browse()
|
||||
if real_records:
|
||||
records |= model.search([(key.name, 'in', real_records.ids)], order='id')
|
||||
records = model.search([(key.name, 'in', real_records.ids)], order='id')
|
||||
if new_records:
|
||||
cache_records = self.env.cache.get_records(model, key)
|
||||
records |= cache_records.filtered(lambda r: set(r[key.name]._ids) & set(self._ids))
|
||||
|
||||
Reference in New Issue
Block a user