diff --git a/addons/web/static/src/views/basic_relational_model.js b/addons/web/static/src/views/basic_relational_model.js index 4d9c58d4d64..3b11f772188 100644 --- a/addons/web/static/src/views/basic_relational_model.js +++ b/addons/web/static/src/views/basic_relational_model.js @@ -1264,6 +1264,7 @@ export class RelationalModel extends Model { const fieldViews = fieldInfo.views || fieldInfo.fieldsInfo || {}; const defaultFieldInfo = legRec.data[name].fieldsInfo.default; _.each(fieldViews, function (fieldView) { + _.defaults(fieldView.fields, defaultFieldInfo); _.each(fieldView.fieldsInfo, function (x2mFieldInfo) { _.defaults(x2mFieldInfo, defaultFieldInfo); }); diff --git a/addons/web/static/tests/views/form/form_view_tests.js b/addons/web/static/tests/views/form/form_view_tests.js index 6dcbcad1fe4..02d766c9a26 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -174,6 +174,7 @@ QUnit.module("Views", (hooks) => { fields: { name: { string: "Partner Type", type: "char" }, color: { string: "Color index", type: "integer" }, + foo: { string: "Foo", type: "char" }, }, records: [ { id: 12, display_name: "gold", color: 2 }, @@ -625,6 +626,53 @@ QUnit.module("Views", (hooks) => { assert.hasClass(target.querySelector('.o_field_widget[name="foo"]'), "text-danger"); }); + QUnit.test( + "form with o2m having a many2many fields using the many2many_tags widget along the color_field option", + async function (assert) { + // In this scenario, the x2many form view isn't inline, so when we click on the record, + // it does an independant getView, which doesn't return all fields of the model. In the + // x2many list view, there's a field with a many2many_tags widget with the color option, + // and the color field (color) in our case, isn't in the form view. + // This test ensures that we can open the form view in this situation. + serverData.models.partner.records[0].timmy = [12, 14]; + serverData.views = { + "partner,false,form": ` +
`, + }; + await makeView({ + type: "form", + resModel: "user", + serverData, + arch: ` + `, + resId: 17, + }); + assert.containsOnce(target, ".o_field_widget[name=timmy] .o_field_tags"); + await click(target.querySelector(".o_data_row .o_data_cell")); + assert.containsOnce(target, ".modal .o_form_view .o_field_widget[name=timmy]"); + } + ); + QUnit.test("decoration-bf works on fields", async function (assert) { await makeView({ type: "form",