From 9db74611ded3dcb64fc57724c032b44d9d170fae Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 31 Oct 2018 16:21:18 +0000 Subject: [IMP] web: action links from bits & pieces Before this, the action manager only supported auto-triggering actions from (model, method) or (action_name). This adds support for providing all the action details via data attributes: * model (defaults to current action's) * resid (defaults to none) * views (defaults to list, form, unless resid is specified then defaults to just form) * domain (defaults to []) * context (defaults to {active_id, active_ids, active_model} from current action if the model has not changed, empty otherwise) The action's name/title is either the link's title (?) or its textual content. --- .../static/tests/views/abstract_controller_tests.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'addons/web/static/tests/views/abstract_controller_tests.js') diff --git a/addons/web/static/tests/views/abstract_controller_tests.js b/addons/web/static/tests/views/abstract_controller_tests.js index cf5810219c7..73bc41d650b 100644 --- a/addons/web/static/tests/views/abstract_controller_tests.js +++ b/addons/web/static/tests/views/abstract_controller_tests.js @@ -43,7 +43,7 @@ odoo.define("base.abstract_controller_tests", function(require) { QUnit.test( 'click on a a[type="action"] child triggers the correct action', function(assert) { - assert.expect(3); + assert.expect(7); var html = "
" + @@ -51,6 +51,9 @@ odoo.define("base.abstract_controller_tests", function(require) { '' + "child" + "" + + 'method' + + 'descr' + + 'descr2' + "
"; var view = createView({ @@ -59,14 +62,24 @@ odoo.define("base.abstract_controller_tests", function(require) { model: "test_model", arch: "", intercepts: { - do_action: function(event) { - assert.step(event.data.action); + do_action: function (event) { + assert.step(event.data.action.name || event.data.action); } + }, + mockRPC: function (route, args) { + if (args.model === 'foo' && args.method === 'bar') { + assert.step("method"); + return $.when({name: 'method'}); + } + return this._super.apply(this, arguments); } }); testUtils.dom.click(view.$(".simple")); testUtils.dom.click(view.$(".with-child span")); - assert.verifySteps(["a1", "a2"]); + testUtils.dom.click(view.$(".method")); + testUtils.dom.click(view.$(".descr")); + testUtils.dom.click(view.$(".descr2")); + assert.verifySteps(["a1", "a2", "method", "method", "descr", "descr2"]); } ); } -- cgit v1.2.3