[FIX] web: kanban: reload after creating a record

In kanban arch, one can set the attribute "on_create" on the root
node to an action xmlid. In this case, when the user clicks on
"Create", the action is executed. When this action is in target
new, it opens a dialog (typically to create a record...). Before
this commit, we didn't reload the kanban after closing the dialog.
As a consequence, the newly created record wasn't displayed. For
instance, it was the case in the Recruitement dashboard.

closes odoo/odoo#99589

Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Aaron Bohy
2022-09-06 10:58:25 +02:00
parent 2600d1f2ae
commit 40c9986d7d
2 changed files with 52 additions and 1 deletions
@@ -89,7 +89,14 @@ export class KanbanController extends Component {
if (onCreate === "quick_create" && root.canQuickCreate()) {
await root.quickCreate(group);
} else if (onCreate && onCreate !== "quick_create") {
await this.actionService.doAction(onCreate, { additionalContext: root.context });
const options = {
additionalContext: root.context,
onClose: async () => {
await this.model.root.load();
this.render(true); // FIXME WOWL reactivity
},
};
await this.actionService.doAction(onCreate, options);
} else {
await this.props.createRecord();
}
@@ -1150,6 +1150,50 @@ QUnit.module("Views", (hooks) => {
}
);
QUnit.test("kanban with an action id as on_create attrs", async (assert) => {
const actionService = {
start() {
return {
doAction: (action, options) => {
// simplified flow in this test: simulate a target new action which
// creates a record and closes itself
assert.step(`doAction ${action}`);
serverData.models.partner.records.push({ id: 299, foo: "new" });
options.onClose();
},
};
},
};
registry.category("services").add("action", actionService, { force: true });
await makeView({
type: "kanban",
resModel: "partner",
serverData,
arch: `
<kanban on_create="some.action">
<templates>
<t t-name="kanban-box">
<div><field name="foo"/></div>
</t>
</templates>
</kanban>`,
mockRPC(route, args) {
assert.step(args.method);
},
});
assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 4);
await createRecord();
assert.containsN(target, ".o_kanban_record:not(.o_kanban_ghost)", 5);
assert.verifySteps([
"get_views",
"web_search_read",
"doAction some.action",
"web_search_read",
]);
});
QUnit.test("create in grouped on m2o", async (assert) => {
await makeView({
type: "kanban",