[FIX] web, *: button special not working to close dialog

*: event_sale
   mail
   sale_product_connfigurator
   stock

Before this commit: if we open dialog from acitivity view and try to
discard it (i.e. close it), it throws traceback.

Issue arises from following commits:
https://github.com/odoo/odoo/commit/d3d576cf8ec9e5b5f6ae5f9d8845cf384435f12d
https://github.com/odoo/odoo/commit/3210f108272be89f1a7b01f4e1816b7f04ae0a3b

Previously, special attribute was passed directly, but now `on_close`
gets action info as an object.

After this commit, it passes special key as an object for `on_close`,
also changed special action based logic in other modules.

Task-Id 2072181

closes odoo/odoo#37078

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
This commit is contained in:
Priyanka Kakadiya
2019-09-27 14:45:51 +00:00
committed by Alexandre Kühn
co-authored by Mohammed Shekha
parent 69bf106a47
commit 9b57bfb6a2
5 changed files with 66 additions and 4 deletions
@@ -113,7 +113,7 @@ ProductConfiguratorWidget.include({
this.do_action('event_sale.event_configurator_action', {
additional_context: data,
on_close: function (result) {
if (result && result !== 'special') {
if (result && !result.special) {
self.trigger_up('field_changed', {
dataPointID: dataPointId,
changes: result.eventConfiguration,
@@ -457,5 +457,64 @@ QUnit.test('activity view: search more to schedule an activity for a record of a
activity.destroy();
});
QUnit.test('Activity view: discard an activity creation dialog', async function (assert) {
assert.expect(2);
var actionManager = await createActionManager({
actions: [{
id: 1,
name: 'Task Action',
res_model: 'task',
type: 'ir.actions.act_window',
views: [[false, 'activity']],
}],
archs: {
'task,false,activity': `
<activity string="Task">
<templates>
<div t-name="activity-box">
<field name="foo"/>
</div>
</templates>
</activity>`,
'task,false,search': '<search></search>',
'mail.activity,false,form': `
<form>
<field name="display_name"/>
<footer>
<button string="Discard" class="btn-secondary" special="cancel"/>
</footer>
</form>`
},
data: this.data,
intercepts: {
do_action(ev) {
actionManager.doAction(ev.data.action, ev.data.options);
}
},
async mockRPC(route, args) {
if (args.method === 'check_access_rights') {
return true;
}
return this._super(...arguments);
},
});
await actionManager.doAction(1);
await testUtils.dom.click(actionManager.$('.o_activity_view .o_data_row .o_activity_empty_cell')[0]);
assert.containsOnce(
$,
'.modal.o_technical_modal.show',
"Activity Modal should be opened");
await testUtils.dom.click($('.modal.o_technical_modal.show button[special="cancel"]'));
assert.containsNone(
$,
'.modal.o_technical_modal.show',
"Activity Modal should be closed");
actionManager.destroy();
});
});
});
@@ -149,7 +149,7 @@ ProductConfiguratorWidget.include({
this.do_action('sale_product_configurator.sale_product_configurator_action', {
additional_context: data,
on_close: function (result) {
if (result && result !== 'special') {
if (result && !result.special) {
self._addProducts(result, dataPointId);
} else {
// is this restoreProductTemplateId ability useful ???
@@ -64,7 +64,7 @@ var InventoryValidationController = ListController.extend({
var exitCallback = function (infos) {
// In case we discarded a wizard, we do nothing to stay on
// the same view...
if (infos === 'special') {
if (infos && infos.special) {
return;
}
// ... but in any other cases, we go back on the inventory form.
@@ -616,7 +616,10 @@ ActionManager.include({
// determine the action to execute according to the actionData
if (actionData.special) {
def = Promise.resolve({type: 'ir.actions.act_window_close', infos: 'special'});
def = Promise.resolve({
type: 'ir.actions.act_window_close',
infos: { special: true },
});
} else if (actionData.type === 'object') {
// call a Python Object method, which may return an action to execute
var args = recordID ? [[recordID]] : [env.resIDs];