diff options
| author | Priyanka Kakadiya <pka@odoo.com> | 2019-09-17 06:56:39 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2019-09-27 14:45:51 +0000 |
| commit | 9b57bfb6a2dcceaa224a64ff8dcfbe7bc6993b1e (patch) | |
| tree | 9afdd9146a99b459019cf5b45671ae9a21c1ad5c /addons | |
| parent | 69bf106a47592d7f868a54b18f8f80ee0491a457 (diff) | |
[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>
Diffstat (limited to 'addons')
5 files changed, 66 insertions, 4 deletions
diff --git a/addons/event_sale/static/src/js/event_configurator_widget.js b/addons/event_sale/static/src/js/event_configurator_widget.js index ea7a5899389..5bbdb3e7033 100644 --- a/addons/event_sale/static/src/js/event_configurator_widget.js +++ b/addons/event_sale/static/src/js/event_configurator_widget.js @@ -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, diff --git a/addons/mail/static/tests/activity_tests.js b/addons/mail/static/tests/activity_tests.js index 8134e6699f5..6c3c297ba5a 100644 --- a/addons/mail/static/tests/activity_tests.js +++ b/addons/mail/static/tests/activity_tests.js @@ -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(); +}); + }); }); diff --git a/addons/sale_product_configurator/static/src/js/product_configurator_widget.js b/addons/sale_product_configurator/static/src/js/product_configurator_widget.js index e10cc7c8898..cf3c4730e26 100644 --- a/addons/sale_product_configurator/static/src/js/product_configurator_widget.js +++ b/addons/sale_product_configurator/static/src/js/product_configurator_widget.js @@ -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 ??? diff --git a/addons/stock/static/src/js/inventory_validate_button_controller.js b/addons/stock/static/src/js/inventory_validate_button_controller.js index ac5367b8d25..3e6899ae0c7 100644 --- a/addons/stock/static/src/js/inventory_validate_button_controller.js +++ b/addons/stock/static/src/js/inventory_validate_button_controller.js @@ -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. diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js index 6027e21bb42..8034a8e54b8 100644 --- a/addons/web/static/src/js/chrome/action_manager_act_window.js +++ b/addons/web/static/src/js/chrome/action_manager_act_window.js @@ -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]; |
