[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
This commit is contained in:
Pierre Masereel
2018-12-05 07:38:30 +00:00
committed by Aaron Bohy
parent 47480a5a89
commit b8c4b42250
2 changed files with 26 additions and 2 deletions
@@ -4418,6 +4418,27 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test('state_selection widget with readonly modifier', function (assert) {
assert.expect(4);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form><field name="selection" widget="state_selection" readonly="1"/></form>',
res_id: 1,
});
assert.hasClass(form.$('.o_selection'), 'o_readonly_modifier');
assert.hasClass(form.$('.o_selection > a'), 'disabled');
assert.isNotVisible(form.$('.dropdown-menu.state'));
testUtils.dom.click(form.$('.o_selection > a'));
assert.isNotVisible(form.$('.dropdown-menu.state'));
form.destroy();
});
QUnit.test('state_selection widget in editable list view', function (assert) {
assert.expect(32);