[FIX] web: list & form: reload view after executing action
Before this commit, the form and list views didn't reload when an action from the ActionMenu (formerly known as "toolbar") was executed. For instance, go to Contacts (list) > select records > Actions > Merge: the contacts are correctly merged, but the view still shows the merged contacts. Note: it worked well for "static" actions like Archive, Delete, this fix only concerns "contextual" actions. closes odoo/odoo#99680 Signed-off-by: Georis François (fge) <fge@odoo.com>
This commit is contained in:
@@ -98,7 +98,7 @@ export class ActionMenus extends Component {
|
||||
const context = makeContext([this.props.context, activeIdsContext]);
|
||||
return this.actionService.doAction(action.id, {
|
||||
additionalContext: context,
|
||||
on_close: () => this.trigger("reload"),
|
||||
onClose: this.props.onActionExecuted,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,5 +141,9 @@ ActionMenus.props = {
|
||||
other: { type: Array, optional: true },
|
||||
},
|
||||
},
|
||||
onActionExecuted: { type: Function, optional: true },
|
||||
};
|
||||
ActionMenus.defaultProps = {
|
||||
onActionExecuted: () => {},
|
||||
};
|
||||
ActionMenus.template = "web.ActionMenus";
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
isDomainSelected="model.root.isDomainSelected"
|
||||
resModel="model.root.resModel"
|
||||
domain="props.domain"
|
||||
onActionExecuted="() => model.load()"
|
||||
/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
domain="props.domain"
|
||||
items="getActionMenuItems()"
|
||||
isDomainSelected="model.root.isDomainSelected"
|
||||
resModel="model.root.resModel"/>
|
||||
resModel="model.root.resModel"
|
||||
onActionExecuted="() => model.load()"/>
|
||||
</t>
|
||||
</t>
|
||||
<t t-component="props.Renderer" list="model.root" activeActions="activeActions" archInfo="archInfo" allowSelectors="props.allowSelectors" editable="editable" openRecord.bind="openRecord" noContentHelp="props.info.noContentHelp" onAdd.bind="createRecord"/>
|
||||
|
||||
@@ -7460,6 +7460,53 @@ QUnit.module("Views", (hooks) => {
|
||||
await toggleMenuItem(target, "Action partner");
|
||||
});
|
||||
|
||||
QUnit.test("execute ActionMenus actions", async function (assert) {
|
||||
const actionService = {
|
||||
start() {
|
||||
return {
|
||||
doAction(id, { additionalContext, onClose }) {
|
||||
assert.step(JSON.stringify({ action_id: id, context: additionalContext }));
|
||||
onClose(); // simulate closing of target new action's dialog
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
registry.category("services").add("action", actionService, { force: true });
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
resId: 1,
|
||||
arch: `<form><field name="bar"/></form>`,
|
||||
info: {
|
||||
actionMenus: {
|
||||
action: [
|
||||
{
|
||||
id: 29,
|
||||
name: "Action partner",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
mockRPC(route, args) {
|
||||
assert.step(args.method);
|
||||
},
|
||||
});
|
||||
|
||||
assert.containsOnce(target, ".o_cp_action_menus .dropdown-toggle:contains(Action)");
|
||||
|
||||
await toggleActionMenu(target);
|
||||
await toggleMenuItem(target, "Action Partner");
|
||||
|
||||
assert.verifySteps([
|
||||
"get_views",
|
||||
"read",
|
||||
`{"action_id":29,"context":{"lang":"en","uid":7,"tz":"taht","active_id":1,"active_ids":[1],"active_model":"partner","active_domain":[]}}`,
|
||||
"read",
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("control panel is not present in FormViewDialogs", async function (assert) {
|
||||
serverData.models.partner.records[0].product_id = 37;
|
||||
serverData.views = {
|
||||
|
||||
@@ -7114,6 +7114,60 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("execute ActionMenus actions", async function (assert) {
|
||||
patchWithCleanup(actionService, {
|
||||
start() {
|
||||
return {
|
||||
doAction(id, { additionalContext, onClose }) {
|
||||
assert.step(JSON.stringify({ action_id: id, context: additionalContext }));
|
||||
onClose(); // simulate closing of target new action's dialog
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: '<tree><field name="foo"/></tree>',
|
||||
info: {
|
||||
actionMenus: {
|
||||
action: [
|
||||
{
|
||||
id: 44,
|
||||
name: "Custom Action",
|
||||
type: "ir.actions.act_window",
|
||||
target: "new",
|
||||
},
|
||||
],
|
||||
print: [],
|
||||
},
|
||||
},
|
||||
actionMenus: {},
|
||||
mockRPC(route, args) {
|
||||
assert.step(args.method);
|
||||
},
|
||||
});
|
||||
|
||||
assert.containsNone(target, "div.o_control_panel .o_cp_action_menus");
|
||||
assert.containsN(target, ".o_data_row", 4);
|
||||
// select all records
|
||||
await click(target, "thead .o_list_record_selector input");
|
||||
assert.containsN(target, ".o_list_record_selector input:checked", 5);
|
||||
assert.containsOnce(target, "div.o_control_panel .o_cp_action_menus");
|
||||
|
||||
await toggleActionMenu(target);
|
||||
await toggleMenuItem(target, "Custom Action");
|
||||
|
||||
assert.verifySteps([
|
||||
"get_views",
|
||||
"web_search_read",
|
||||
`{"action_id":44,"context":{"lang":"en","uid":7,"tz":"taht","active_id":1,"active_ids":[1,2,3,4],"active_model":"foo","active_domain":[]}}`,
|
||||
"web_search_read",
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"execute ActionMenus actions with correct params (single page)",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user