diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-07-04 13:34:51 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-07-09 07:59:05 +0000 |
| commit | ea2207afeab8c4d8da6b010aebd99f896e04359b (patch) | |
| tree | d0911418ee1e59c673750ae68896f660a255949d /addons/web/static/tests/chrome | |
| parent | 9cab694bf594f6c7c8d795174d9159ac82f526b2 (diff) | |
[FIX] web: don't close dialog on doAction with target 'new'
Rev. ee44d23 fixed a usability issue: when a doAction is performed
from a dialog, it automatically closes the dialog (as the action is
rendered in the background, behind the dialog).
However, it also closes dialogs when the action has target='new',
i.e. when it also opens in a dialog, which is not strictly
necessary in this case.
This is problematic in mobile for the product configurator widget:
in the sale.order form view, the order_line field is displayed as a
kanban, and in its form view, the product_(template_)id field has
widget product_configurator. When a value is set, it performs a
doAction (target="new") to configure the product. The widget listens
to the dialog's 'closed' event to update itself. However, with what
is done in ee44d23, the x2many form dialog is closed by the DoAction,
so the flow doesn't work.
This rev. reverts the attempt done in ee44d23, and does something a
bit more brutal: as soon as an action is pushed in target 'current'
(in the main part of the interface), all dialogs are automatically
closed.
closes odoo/odoo#34678
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Diffstat (limited to 'addons/web/static/tests/chrome')
| -rw-r--r-- | addons/web/static/tests/chrome/action_manager_tests.js | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 578fcfbd660..8a6675ecc58 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -23,13 +23,14 @@ QUnit.module('ActionManager', { fields: { foo: {string: "Foo", type: "char"}, bar: {string: "Bar", type: "many2one", relation: 'partner'}, + o2m: {string: "One2Many", type: "one2many", relation: 'partner', relation_field: 'bar'}, }, records: [ - {id: 1, display_name: "First record", foo: "yop", bar: 2}, - {id: 2, display_name: "Second record", foo: "blip", bar: 1}, - {id: 3, display_name: "Third record", foo: "gnap", bar: 1}, - {id: 4, display_name: "Fourth record", foo: "plop", bar: 2}, - {id: 5, display_name: "Fifth record", foo: "zoup", bar: 2}, + {id: 1, display_name: "First record", foo: "yop", bar: 2, o2m: [2, 3]}, + {id: 2, display_name: "Second record", foo: "blip", bar: 1, o2m: [1, 4, 5]}, + {id: 3, display_name: "Third record", foo: "gnap", bar: 1, o2m: []}, + {id: 4, display_name: "Fourth record", foo: "plop", bar: 2, o2m: []}, + {id: 5, display_name: "Fifth record", foo: "zoup", bar: 2, o2m: []}, ], }, pony: { @@ -512,6 +513,68 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('executing an action with target != "new" closes all dialogs', async function (assert) { + assert.expect(4); + + this.archs['partner,false,form'] = '<form>' + + '<field name="o2m">' + + '<tree><field name="foo"/></tree>' + + '<form><field name="foo"/></form>' + + '</field>' + + '</form>'; + + var actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + }); + + await actionManager.doAction(3); + assert.containsOnce(actionManager, '.o_list_view'); + + await testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first')); + assert.containsOnce(actionManager, '.o_form_view'); + + await testUtils.dom.click(actionManager.$('.o_form_view .o_data_row:first')); + assert.containsOnce(document.body, '.modal .o_form_view'); + + await actionManager.doAction(1); // target != 'new' + assert.containsNone(document.body, '.modal'); + + actionManager.destroy(); + }); + + QUnit.test('executing an action with target "new" does not close dialogs', async function (assert) { + assert.expect(4); + + this.archs['partner,false,form'] = '<form>' + + '<field name="o2m">' + + '<tree><field name="foo"/></tree>' + + '<form><field name="foo"/></form>' + + '</field>' + + '</form>'; + + var actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + }); + + await actionManager.doAction(3); + assert.containsOnce(actionManager, '.o_list_view'); + + await testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first')); + assert.containsOnce(actionManager, '.o_form_view'); + + await testUtils.dom.click(actionManager.$('.o_form_view .o_data_row:first')); + assert.containsOnce(document.body, '.modal .o_form_view'); + + await actionManager.doAction(5); // target 'new' + assert.containsN(document.body, '.modal .o_form_view', 2); + + actionManager.destroy(); + }); + QUnit.module('Push State'); QUnit.test('properly push state', async function (assert) { @@ -3849,7 +3912,6 @@ QUnit.module('ActionManager', { delete core.action_registry.map.slowAction; }); - QUnit.test('abstract action does not crash on navigation_moves', async function (assert) { assert.expect(1); var ClientAction = AbstractAction.extend({ |
