diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index decaf1884b2..fe4ba14de71 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -392,7 +392,7 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, { */ _onActionClicked: function (event) { event.preventDefault(); - this.do_action(event.target.name); + this.do_action(event.currentTarget.name); }, /** * Intercepts the 'switch_view' event to add the controllerID into the data, diff --git a/addons/web/static/tests/views/abstract_controller_tests.js b/addons/web/static/tests/views/abstract_controller_tests.js new file mode 100644 index 00000000000..c9b7daa45dc --- /dev/null +++ b/addons/web/static/tests/views/abstract_controller_tests.js @@ -0,0 +1,74 @@ +odoo.define("base.abstract_controller_tests", function(require) { + "use strict"; + + var testUtils = require("web.test_utils"); + var createView = testUtils.createView; + var BasicView = require("web.BasicView"); + var BasicRenderer = require("web.BasicRenderer"); + + function getHtmlRenderer(html) { + return BasicRenderer.extend({ + start: function() { + this.$el.html(html); + return this._super.apply(this, arguments); + } + }); + } + function getHtmlView(html, viewType) { + viewType = viewType || "test"; + return BasicView.extend({ + viewType: viewType, + config: _.extend({}, BasicView.prototype.config, { + Renderer: getHtmlRenderer(html) + }) + }); + } + + QUnit.module( + "Views", + { + beforeEach: function() { + this.data = { + test_model: { + fields: {}, + records: [] + } + }; + } + }, + function() { + + QUnit.module('AbstractController'); + + QUnit.test( + 'click on a a[type="action"] child triggers the correct action', + function(assert) { + assert.expect(3); + + var html = + "
" + + 'simple' + + '' + + "child" + + "" + + "
"; + + var view = createView({ + View: getHtmlView(html, "test"), + data: this.data, + model: "test_model", + arch: "", + intercepts: { + do_action: function(event) { + assert.step(event.data.action); + } + } + }); + view.$(".simple").click(); + view.$(".with-child span").click(); + assert.verifySteps(["a1", "a2"]); + } + ); + } + ); +}); diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index d4d0a1e8c37..6bd1bcfa12b 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -507,6 +507,7 @@ +