[IMP] web: close confirm dialog if unlink raises error
before this commit: deleting records from listview shows confirm dialog, if unlink method throws UserError then there will be two dialog, closing UserError dialog and clicking on OK button in confirm dialog will again call unlink method which will open UserError dialog again, when error thwon from unlink error then confirm dialog should close. after this commit: if error is thrown from unlink and confirm dialog is opened then cofirm dialog will close first and then error dialog will be shown, this is done to avoid situation explained above. task-2221075 closes odoo/odoo#60265 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
parent
de0d05b6a6
commit
a58699cb87
@@ -344,7 +344,11 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
|
||||
const message = ids.length > 1 ?
|
||||
_t("Are you sure you want to delete these records?") :
|
||||
_t("Are you sure you want to delete this record?");
|
||||
Dialog.confirm(this, message, { confirm_callback: doIt });
|
||||
let dialog;
|
||||
const confirmCallback = () => {
|
||||
doIt().guardedCatch(() => dialog.destroy());
|
||||
};
|
||||
dialog = Dialog.confirm(this, message, { confirm_callback: confirmCallback });
|
||||
} else {
|
||||
doIt();
|
||||
}
|
||||
|
||||
@@ -3350,6 +3350,37 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('deleting record which throws UserError should close confirmation dialog', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const list = await createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
viewOptions: {hasActionMenus: true},
|
||||
arch: '<tree><field name="foo"/></tree>',
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'unlink') {
|
||||
return Promise.reject({ message: "Odoo Server Error" });
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.dom.click(list.$('tbody td.o_list_record_selector:first input'));
|
||||
|
||||
assert.containsOnce(list.el, 'div.o_control_panel .o_cp_action_menus');
|
||||
|
||||
await cpHelpers.toggleActionMenu(list);
|
||||
await cpHelpers.toggleMenuItem(list, "Delete");
|
||||
assert.containsOnce(document.body, '.modal', 'should have open the confirmation dialog');
|
||||
|
||||
await testUtils.dom.click($('body .modal button span:contains(Ok)'));
|
||||
assert.containsNone(document.body, ".modal", "confirmation dialog should be closed");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('delete all records matching the domain', async function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user