diff --git a/addons/stock/static/src/js/stock_traceability_report_backend.js b/addons/stock/static/src/js/stock_traceability_report_backend.js index f723ade6961..6a504cd2b12 100644 --- a/addons/stock/static/src/js/stock_traceability_report_backend.js +++ b/addons/stock/static/src/js/stock_traceability_report_backend.js @@ -99,10 +99,6 @@ var stock_report_generic = AbstractAction.extend({ }); return this.$buttons; }, - do_show: function() { - this._super(); - this.update_cp(); - }, }); core.action_registry.add("stock_report_generic", stock_report_generic); diff --git a/addons/stock/static/tests/stock_traceability_report_backend_tests.js b/addons/stock/static/tests/stock_traceability_report_backend_tests.js index 20a9d809d70..5ab69403544 100644 --- a/addons/stock/static/tests/stock_traceability_report_backend_tests.js +++ b/addons/stock/static/tests/stock_traceability_report_backend_tests.js @@ -1,10 +1,13 @@ odoo.define('stock.stock_traceability_report_backend_tests', function (require) { "use strict"; + const ControlPanel = require('web.ControlPanel'); const dom = require('web.dom'); const StockReportGeneric = require('stock.stock_report_generic'); const testUtils = require('web.test_utils'); + const { createActionManager, dom: domUtils } = testUtils; + /** * Helper function to instantiate a stock report action. * @param {Object} params @@ -67,5 +70,82 @@ odoo.define('stock.stock_traceability_report_backend_tests', function (require) report.destroy(); }); + + QUnit.test("mounted is called once when returning on 'Stock 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; + + 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: "Stock report", + tag: 'stock_report_generic', + type: 'ir.actions.client', + context: {}, + params: {}, + }, + ], + archs: { + 'partner,false,form': '
', + 'partner,false,search': '', + }, + data: { + partner: { + fields: { + display_name: { string: "Displayed name", type: "char" }, + }, + records: [ + {id: 1, display_name: "Genda Swami"}, + ], + }, + }, + mockRPC: function (route) { + if (route === '/web/dataset/call_kw/stock.traceability.report/get_html') { + return Promise.resolve({ + html: 'Go to form view', + }); + } + return this._super.apply(this, arguments); + }, + intercepts: { + do_action: ev => actionManager.doAction(ev.data.action, ev.data.options), + }, + }); + + await actionManager.doAction(42); + await domUtils.click(actionManager.$('.o_stock_reports_web_action')); + await domUtils.click(actionManager.$('.breadcrumb-item:first')); + actionManager.destroy(); + + assert.verifySteps([ + 'mounted 1', + 'willUnmount 1', + 'mounted 2', + 'willUnmount 2', + 'mounted 3', + 'willUnmount 3', + ]); + + ControlPanel.unpatch('test.ControlPanel'); + }); }); });