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 = + "