summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorQiuyu (QHO) <qho@odoo.com>2021-02-22 15:42:06 +0000
committerQiuyu (QHO) <qho@odoo.com>2021-02-23 07:36:23 +0000
commita3f5d0b292361a4aa3af8e7662f74150c5d85254 (patch)
treef645b008896baa95d82821c4dcb23f395b5bc657 /addons
parent79d834f2c2ec167831fe0986afb728207a467d67 (diff)
[FIX] mail: functions for FieldCommand should return boolean value
The executing function for FieldCommand should return boolean value to indicate whether the value changed for triggering the re-computation. closes odoo/odoo#66648 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/static/src/model/model_field_command.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/mail/static/src/model/model_field_command.js b/addons/mail/static/src/model/model_field_command.js
index a6dadb7b983..f4e59a957f3 100644
--- a/addons/mail/static/src/model/model_field_command.js
+++ b/addons/mail/static/src/model/model_field_command.js
@@ -9,7 +9,9 @@ odoo.define('mail/static/src/model/model_field_command.js', function (require) {
class FieldCommand {
/**
* @constructor
- * @param {function} func function to call when executing this command
+ * @param {function} func function to call when executing this command.
+ * The function should ALWAYS return a boolean value
+ * to indicate whether the value changed.
*/
constructor(func) {
this.func = func;
@@ -43,7 +45,7 @@ function clear() {
function decrement(amount = 1) {
return new FieldCommand((field, record, options) => {
const oldValue = field.get(record);
- field.set(record, oldValue - amount, options);
+ return field.set(record, oldValue - amount, options);
});
}
@@ -55,7 +57,7 @@ function decrement(amount = 1) {
function increment(amount = 1) {
return new FieldCommand((field, record, options) => {
const oldValue = field.get(record);
- field.set(record, oldValue + amount, options);
+ return field.set(record, oldValue + amount, options);
});
}