diff --git a/addons/web/static/src/js/report/client_action.js b/addons/web/static/src/js/report/client_action.js index 9b7d1fb6124..d4cb3096aea 100644 --- a/addons/web/static/src/js/report/client_action.js +++ b/addons/web/static/src/js/report/client_action.js @@ -53,15 +53,6 @@ var ReportAction = AbstractAction.extend({ }); }, - do_show: function () { - this.updateControlPanel({ - cp_content: { - $buttons: this.$buttons, - }, - }); - return this._super.apply(this, arguments); - }, - on_attach_callback: function () { // Register now the postMessage event handler. We only want to listen to ~trusted // messages and we can only filter them by their origin, so we chose to ignore the diff --git a/addons/web/static/tests/report/client_action_tests.js b/addons/web/static/tests/report/client_action_tests.js new file mode 100644 index 00000000000..c537f6c2540 --- /dev/null +++ b/addons/web/static/tests/report/client_action_tests.js @@ -0,0 +1,111 @@ +odoo.define('web/static/tests/report/client_action_tests', function (require) { + "use strict"; + + const ControlPanel = require('web.ControlPanel'); + const ReportClientAction = require('report.client_action'); + const testUtils = require("web.test_utils"); + + const { createActionManager, dom, mock } = testUtils; + + QUnit.module('Client Action Report', {}, () => { + QUnit.test("mounted is called once when returning on 'Client Action Report' from breadcrumb", async assert => { + // This test can be removed as soon as we don't mix legacy and owl layers anymore. + assert.expect(7); + + let mountCount = 0; + + // patch the report client action to override its iframe's url so that + // it doesn't trigger an RPC when it is appended to the DOM (for this + // usecase, using removeSRCAttribute doesn't work as the RPC is + // triggered as soon as the iframe is in the DOM, even if its src + // attribute is removed right after) + mock.patch(ReportClientAction, { + start: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + self._rpc({route: self.iframe.getAttribute('src')}); + self.iframe.setAttribute('src', 'about:blank'); + }); + } + }); + + ControlPanel.patch('test.ControlPanel', T => { + class ControlPanelPatchTest extends T { + mounted() { + mountCount = mountCount + 1; + this.__uniqueId = mountCount; + assert.step(`mounted ${this.__uniqueId}`); + super.mounted(...arguments); + } + willUnmount() { + assert.step(`willUnmount ${this.__uniqueId}`); + super.mounted(...arguments); + } + } + return ControlPanelPatchTest; + }); + const actionManager = await createActionManager({ + actions: [ + { + id: 42, + name: "Client Action Report", + tag: 'report.client_action', + type: 'ir.actions.report', + report_type: 'qweb-html', + }, + { + id: 43, + type: "ir.actions.act_window", + res_id: 1, + res_model: "partner", + views: [ + [false, "form"], + ], + } + ], + archs: { + 'partner,false,form': '
', + 'partner,false,search': '