[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
This commit is contained in:
Sébastien Theys
2023-12-08 15:57:52 +00:00
parent 70526f74ee
commit 4d5c2007d9
+3 -1
View File
@@ -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, {