diff --git a/addons/web/static/src/views/form/form_controller.js b/addons/web/static/src/views/form/form_controller.js index bf9df625deb..8f71d75d7b5 100644 --- a/addons/web/static/src/views/form/form_controller.js +++ b/addons/web/static/src/views/form/form_controller.js @@ -103,17 +103,23 @@ export class FormController extends Component { const beforeLoadProm = new Promise((r) => { this.beforeLoadResolver = r; }); - this.model = useModel(this.props.Model, { - resModel: this.props.resModel, - resId: this.props.resId || false, - resIds: this.props.resIds, - fields: this.props.fields, - activeFields, - viewMode: "form", - rootType: "record", - mode: this.props.mode, - beforeLoadProm, - }); + this.model = useModel( + this.props.Model, + { + resModel: this.props.resModel, + resId: this.props.resId || false, + resIds: this.props.resIds, + fields: this.props.fields, + activeFields, + viewMode: "form", + rootType: "record", + mode: this.props.mode, + beforeLoadProm, + }, + { + ignoreUseSampleModel: true, + } + ); const { create, edit } = this.archInfo.activeActions; this.canCreate = create && !this.props.preventCreate; diff --git a/addons/web/static/src/views/model.js b/addons/web/static/src/views/model.js index 5941e9fcdc7..fea46f92b37 100644 --- a/addons/web/static/src/views/model.js +++ b/addons/web/static/src/views/model.js @@ -119,18 +119,21 @@ export function useModel(ModelClass, params, options = {}) { async function load(props) { const searchParams = getSearchParams(props); await model.load(searchParams); - if (useSampleModel && !model.hasData()) { - sampleORM = - sampleORM || buildSampleORM(component.props.resModel, component.props.fields, user); - sampleORM.setGroups(model.getGroups()); - // Load data with sampleORM then restore real ORM. - model.orm = sampleORM; - await model.load(searchParams); - model.orm = orm; - } else { - useSampleModel = false; + if (!options.ignoreUseSampleModel) { + if (useSampleModel && !model.hasData()) { + sampleORM = + sampleORM || + buildSampleORM(component.props.resModel, component.props.fields, user); + sampleORM.setGroups(model.getGroups()); + // Load data with sampleORM then restore real ORM. + model.orm = sampleORM; + await model.load(searchParams); + model.orm = orm; + } else { + useSampleModel = false; + model.useSampleModel = useSampleModel; + } } - model.useSampleModel = useSampleModel; if (started) { model.notify(); } diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js index 48ea011465c..ba58fb546a8 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -2393,4 +2393,37 @@ QUnit.module("ActionManager", (hooks) => { // mode is "edit" because target="new" assert.containsOnce(target, ".o_form_view .o_form_editable"); }); + + QUnit.test("action group_by of type string", async function (assert) { + serverData.models.partner.records = []; + serverData.views["partner,false,list"] = ` + + + + `; + serverData.views["partner,false,form"] = ` +
+ + + `; + registry.category("services").add("user", makeFakeUserService()); + const webClient = await createWebClient({ serverData }); + await doAction(webClient, { + name: "Partner", + res_model: "partner", + type: "ir.actions.act_window", + views: [ + [false, "list"], + [false, "form"], + ], + }); + + assert.containsOnce(target, ".o_list_view .o_content.o_view_sample_data"); + + await click(target.querySelector(".o_list_view .o_list_button_add")); + + await click(target.querySelector(".o_form_view .breadcrumb-item a")); + + assert.containsOnce(target, ".o_list_view .o_content.o_view_sample_data"); + }); });