[FIX] web: readonly many2one in list views
Fixes the way many2one fields are rendered in editable list views. Before this commit, many2ones in readonly mode would render as links and their widget would be considered as active even though you couldn't edit it. Now, they are rendered as plain text and act the same way as readonly char fields.
This commit is contained in:
@@ -766,6 +766,25 @@ var FieldMany2One = AbstractField.extend({
|
||||
});
|
||||
|
||||
var ListFieldMany2One = FieldMany2One.extend({
|
||||
events: _.extend({}, FieldMany2One.prototype.events, {
|
||||
'focusin input': '_onInputFocusin',
|
||||
}),
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* If in readonly, will never be considered as an active widget.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
activate: function () {
|
||||
if (this.mode === 'readonly') {
|
||||
return false;
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
|
||||
@@ -829,8 +829,8 @@
|
||||
|
||||
<t t-name="FieldMany2One">
|
||||
<t t-if="widget.mode === 'readonly'">
|
||||
<a t-if="!widget.nodeOptions.no_open" t-att-tabindex="widget.attrs.tabindex" class="o_form_uri" href="#"/>
|
||||
<span t-if="widget.nodeOptions.no_open"/>
|
||||
<a t-if="!widget.noOpen" t-att-tabindex="widget.attrs.tabindex" class="o_form_uri" href="#"/>
|
||||
<span t-if="widget.noOpen"/>
|
||||
</t>
|
||||
<div t-if="widget.mode === 'edit'" class="o_field_widget o_field_many2one" aria-atomic="true">
|
||||
<div class="o_input_dropdown">
|
||||
|
||||
@@ -4703,6 +4703,30 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('editable list view: many2one with readonly modifier', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const list = await createView({
|
||||
arch:
|
||||
`<tree editable="top">
|
||||
<field name="m2o" readonly="1"/>
|
||||
<field name="foo"/>
|
||||
</tree>`,
|
||||
data: this.data,
|
||||
model: 'foo',
|
||||
View: ListView,
|
||||
});
|
||||
|
||||
// edit a field
|
||||
await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_data_cell:eq(0)'));
|
||||
|
||||
assert.containsOnce(list, '.o_data_row:eq(0) .o_data_cell:eq(0) a[name="m2o"]');
|
||||
assert.strictEqual(document.activeElement, list.$('.o_data_row:eq(0) .o_data_cell:eq(1) input')[0],
|
||||
"focus should go to the char input");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('list grouped by date:month', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user