[IMP] base: avoid ormcache clear when setting ir.default to the same value

Purpose
=======

On the res.config.settings model for example, calling execute without
having changed a single parameter will make several writes on
ir.default records.

However, even if the written and the current values are the same,
the cache will be invalidated several times.

Part-of: odoo/odoo#82999
This commit is contained in:
Yannick Tivisse
2022-02-08 14:53:37 +00:00
parent f448b3314e
commit fd6bc0cb61
+3 -1
View File
@@ -80,7 +80,9 @@ class IrDefault(models.Model):
('condition', '=', condition),
])
if default:
default.write({'json_value': json_value})
# Avoid clearing the cache if nothing changes
if default.json_value != json_value:
default.write({'json_value': json_value})
else:
self.create({
'field_id': field.id,