From 4d5c2007d9169fc89ddddac2318cbae5694bdcf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Thu, 7 Dec 2023 16:09:03 +0100 Subject: [PATCH] [FIX] mail: fix perf of models by removing useless onChange onChange on each field is extremely costly, and it's not actually used unless the field is computed or sorted. Time of test "Load 100 recipients at once" is divied by more than 2. Part-of: odoo/odoo#145442 --- addons/mail/static/src/core/common/record.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/core/common/record.js b/addons/mail/static/src/core/common/record.js index 1886ff1889e..7acabf05219 100644 --- a/addons/mail/static/src/core/common/record.js +++ b/addons/mail/static/src/core/common/record.js @@ -238,7 +238,9 @@ export function makeStore(env) { this[name] = defaultVal; } const rfield = toRaw(field); - onChange(proxy, name, () => (rfield.changed = true)); + if (compute || sort) { + onChange(proxy, name, () => (rfield.changed = true)); + } if (compute) { const proxy2 = reactive(proxy, () => rfield.requestCompute()); Object.assign(rfield, {