summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorDharmang Soni <dpr@openerp.com>2018-04-25 11:10:51 +0530
committerAaron Bohy <aab@odoo.com>2018-08-14 13:51:07 +0200
commit4dfabb8f7adde06a7936502af61534c9958ed4f7 (patch)
tree4f349b97a09e78f0042e9088ae598ff7b7271407 /addons/web/static/src
parent92bdd0e7c5a4ba13f1874e1aec2e379745e5660e (diff)
[IMP] web: FieldSelection: no empty value if required
From this rev., the empty value isn't available in the options of required selection fields, thus preventing the user to unset it. Related to task #49262 Closes #24404
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 936a27c739b..b8eb106caab 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -2166,6 +2166,19 @@ var FieldSelection = AbstractField.extend({
isSet: function () {
return this.value !== false;
},
+ /**
+ * Listen to modifiers updates to hide/show the falsy value in the dropdown
+ * according to the required modifier.
+ *
+ * @override
+ */
+ updateModifiersValue: function () {
+ this._super.apply(this, arguments);
+ if (!this.attrs.modifiersValue.invisible && this.mode !== 'readonly') {
+ this._setValues();
+ this._renderEdit();
+ }
+ },
//--------------------------------------------------------------------------
// Private
@@ -2219,7 +2232,9 @@ var FieldSelection = AbstractField.extend({
return v[0] === false && v[1] === '';
});
}
- this.values = [[false, this.attrs.placeholder || '']].concat(this.values);
+ if (!this.attrs.modifiersValue || !this.attrs.modifiersValue.required) {
+ this.values = [[false, this.attrs.placeholder || '']].concat(this.values);
+ }
},
//--------------------------------------------------------------------------