[FIX] web: do not clearUncommittedChanges for function actions
Before this commit: In res.config.settings form view when user change something in form and click on button in form then it will display to save the unsaved changes, when we click 'Save' button from dialog still dialog remain there it is not closed(while record is saved in background, just dialog is not closed) This is because we called 'clearUncommittedChanges' method before executing client action, 'Save' button on dialog returns client action for reload page but as we calling 'clearUncommittedChanges' so it will call 'canBeDiscarded' method of 'BaseSettingController' which again show dialog for unsaved changes. After this commit: unsaved changes dialog is closed on clicking 'Save' button from dialog, we called 'clearUncommittedChanges' method only if clientAction is instance of Component, i.e. if client action is type of function which is our case, reload is client action which type of function so in that case we do not need to call 'clearUncommittedChanges'. task-2662302 closes odoo/odoo#78035 X-original-commit: 5d8376a8f9a8957112afb35854bdb8b050bd6903 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
parent
c0e354eeec
commit
49b35e85ca
@@ -841,8 +841,11 @@ function makeActionManager(env) {
|
||||
async function _executeClientAction(action, options) {
|
||||
const clientAction = actionRegistry.get(action.tag);
|
||||
if (clientAction.prototype instanceof Component) {
|
||||
if (action.target !== "new" && clientAction.target) {
|
||||
action.target = clientAction.target;
|
||||
if (action.target !== "new") {
|
||||
await clearUncommittedChanges(env);
|
||||
if (clientAction.target) {
|
||||
action.target = clientAction.target;
|
||||
}
|
||||
}
|
||||
const controller = {
|
||||
jsId: `controller_${++id}`,
|
||||
@@ -1078,9 +1081,6 @@ function makeActionManager(env) {
|
||||
case "ir.actions.act_window_close":
|
||||
return _executeCloseAction({ onClose: options.onClose, onCloseInfo: action.infos });
|
||||
case "ir.actions.client":
|
||||
if (action.target !== "new") {
|
||||
await clearUncommittedChanges(env);
|
||||
}
|
||||
return _executeClientAction(action, options);
|
||||
case "ir.actions.report":
|
||||
return _executeReportAction(action, options);
|
||||
|
||||
@@ -131,6 +131,25 @@ QUnit.module("ActionManager", (hooks) => {
|
||||
assert.containsOnce(webClient, ".o_kanban_view");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"'CLEAR-UNCOMMITTED-CHANGES' is not triggered for function client actions",
|
||||
async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
registry.category("actions").add("my_action", async () => {
|
||||
assert.step("my_action");
|
||||
});
|
||||
|
||||
const webClient = await createWebClient({ serverData });
|
||||
webClient.env.bus.on("CLEAR-UNCOMMITTED-CHANGES", webClient, () => {
|
||||
assert.step("CLEAR-UNCOMMITTED-CHANGES");
|
||||
});
|
||||
|
||||
await doAction(webClient, "my_action");
|
||||
assert.verifySteps(["my_action"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("client action with control panel (legacy)", async function (assert) {
|
||||
assert.expect(4);
|
||||
// LPE Fixme: at this time we don't really know the API that wowl ClientActions implement
|
||||
|
||||
Reference in New Issue
Block a user