From d310cd447850d8451b9b51b0e3b6243734cddaef Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Thu, 22 Aug 2019 16:06:02 +0000 Subject: [FIX] web: selection: required, option present but disabled Before this commit, a field selection which was required did not have an empty option ref: 4dfabb8f7adde06a7936502af61534c9958ed4f7 This is fine, but overlooked the fact that modules can modify the required attribute, or even views can do it So, we may end up in a situation where the field is required but set to false This configuration is problematic, at least for the timezone selection field (see OPW) After this commit, the empty option is just not visible note that `disabled = True` would not work because val is not accessible Because of commits: - 4dfabb8f7adde06a7936502af61534c9958ed4f7 for the selection feature - d77ce4c2a92c1da48150e4e84b714dd93f64847d overriding the required attribute of tz in res.user form OPW 2057913 closes odoo/odoo#35989 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/fields/relational_fields.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 0f247ba3a8d..13e58095d40 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -2471,10 +2471,14 @@ var FieldSelection = AbstractField.extend({ */ _renderEdit: function () { this.$el.empty(); + var required = this.attrs.modifiersValue && this.attrs.modifiersValue.required; for (var i = 0 ; i < this.values.length ; i++) { + var disabled = required && this.values[i][0] === false; + this.$el.append($('