summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/abstract_field.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/abstract_field.js')
-rw-r--r--addons/web/static/src/js/fields/abstract_field.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js
index ab6f226a66e..16e928ea288 100644
--- a/addons/web/static/src/js/fields/abstract_field.js
+++ b/addons/web/static/src/js/fields/abstract_field.js
@@ -404,6 +404,18 @@ var AbstractField = Widget.extend({
return `text-${decoration.split('-')[1]}`;
},
/**
+ * Compares the given value with the last value that has been set.
+ * Note that we compare unparsed values. Handles the special case where no
+ * value has been set yet, and the given value is the empty string.
+ *
+ * @private
+ * @param {any} value
+ * @returns {boolean} true iff values are the same
+ */
+ _isLastSetValue: function (value) {
+ return this.lastSetValue === value || (this.value === false && value === '');
+ },
+ /**
* This method check if a value is the same as the current value of the
* field. For example, a fieldDate widget might want to use the moment
* specific value isSame instead of ===.
@@ -499,9 +511,8 @@ var AbstractField = Widget.extend({
* @returns {Promise}
*/
_setValue: function (value, options) {
- // we try to avoid doing useless work, if the value given has not
- // changed. Note that we compare the unparsed values.
- if (this.lastSetValue === value || (this.value === false && value === '')) {
+ // we try to avoid doing useless work, if the value given has not changed.
+ if (this._isLastSetValue(value)) {
return Promise.resolve();
}
this.lastSetValue = value;