summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2018-12-03 11:05:52 +0000
committerAaron Bohy <aab@odoo.com>2018-12-05 07:38:30 +0000
commitb8c4b42250b9caf2ac4fef32cc85dab05ccc3b08 (patch)
tree2995ddc0d1afc5944d346af0b05f2a76536a70f1 /addons/web/static/src/js/fields
parent47480a5a8991be1a5bcfd8798d45741c25fc69f6 (diff)
[IMP] web: state_selection widget readonly if field readonly
The current implementation of the state_selection widget always makes it editable even if the field is readonly. We improved this behavior by removing the handle of click on the widget when the field is readonly, but keeping it even if the view is not in edit mode, because it used for example in project to change state even when view is not editable. closes odoo/odoo#29218
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index aac91081c3c..4d266db409d 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1960,11 +1960,10 @@ var StateSelectionWidget = AbstractField.extend({
* @override
*/
_render: function () {
- var self = this;
var states = this._prepareDropdownValues();
// Adapt "FormSelection"
// Like priority, default on the first possible value if no value is given.
- var currentState = _.findWhere(states, {name: self.value}) || states[0];
+ var currentState = _.findWhere(states, {name: this.value}) || states[0];
this.$('.o_status')
.removeClass('o_status_red o_status_green')
.addClass(currentState.state_class)
@@ -1979,6 +1978,10 @@ var StateSelectionWidget = AbstractField.extend({
var $dropdown = this.$('.dropdown-menu');
$dropdown.children().remove(); // remove old items
$items.appendTo($dropdown);
+
+ // Disable edition if the field is readonly
+ var isReadonly = this.record.evalModifiers(this.attrs.modifiers).readonly;
+ this.$('a[data-toggle=dropdown]').toggleClass('disabled', isReadonly || false);
},
//--------------------------------------------------------------------------