diff options
Diffstat (limited to 'addons/mail/static/src/model')
| -rw-r--r-- | addons/mail/static/src/model/model_field_command.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/mail/static/src/model/model_field_command.js b/addons/mail/static/src/model/model_field_command.js index 89f42651ad9..a6dadb7b983 100644 --- a/addons/mail/static/src/model/model_field_command.js +++ b/addons/mail/static/src/model/model_field_command.js @@ -35,11 +35,37 @@ function clear() { ); } +/** + * Returns a decrement command to give to the model manager at create/update. + * + * @param {number} [amount=1] + */ +function decrement(amount = 1) { + return new FieldCommand((field, record, options) => { + const oldValue = field.get(record); + field.set(record, oldValue - amount, options); + }); +} + +/** + * Returns a increment command to give to the model manager at create/update. + * + * @param {number} [amount=1] + */ +function increment(amount = 1) { + return new FieldCommand((field, record, options) => { + const oldValue = field.get(record); + field.set(record, oldValue + amount, options); + }); +} + return { // class FieldCommand, // shortcuts clear, + decrement, + increment, }; }); |
