diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 4c05946cf23..06f38abffbb 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -532,7 +532,7 @@ var FieldX2Many = AbstractField.extend({ this._super.apply(this, arguments); this.operations = []; this.isReadonly = this.mode === 'readonly'; - this.view = this.attrs.views.list || this.attrs.views.kanban; + this.view = this.attrs.views[this.attrs.mode]; this.activeActions = {}; this.recordParams = {fieldName: this.name, viewType: this.viewType}; var arch = this.view && this.view.arch; diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 4f06bc93bee..6b23940a9db 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -2737,6 +2737,40 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('x2many fields use their "mode" attribute', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
', + res_id: 1, + }); + + assert.strictEqual(form.$('.o_form_field_one2many .o_kanban_view').length, 1, + "should have rendered a kanban view"); + + form.destroy(); + }); + QUnit.module('FieldMany2Many'); QUnit.test('many2many kanban: edition', function (assert) {