[FIX] stock,mrp: render control panel components

Since 362f6b6d5b, the control panel of an
action can be rendered only the first time the dom is mounted. Any
further remount won't rerenders do anything. The bom report needs to add
some buttons and a searchView. Previously, those widgets was mounted in
the set_html _after_ the first mount of the controlPanel. This report is
an extend of the stock traceability which also adds some buttons. In
this case the buttons are rendered correctly because they are added
_before_ the first controlPanel mount.

This commit makes the extra widgets to be rendered in the control panel
generated in a new specific method overridable in the bom report file

closes odoo/odoo#93245

X-original-commit: 39306370a3a7c5767a29bba216ffe61ab8c69544
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
William Henrotin
2022-06-10 09:28:09 +02:00
parent a95cb2eb2d
commit 63d068e94d
2 changed files with 12 additions and 1 deletions
@@ -130,6 +130,13 @@ var MrpBomReport = stock_report_generic.extend({
};
return this.updateControlPanel(status);
},
getControlPanelProps: function() {
this.renderSearch();
return {
$buttons: this.$buttonsPanel,
$searchview: this.$searchView
}
},
renderSearch: function () {
this.$buttonsPanel = $(QWeb.render('mrp.button', {'is_variant_applied': this.data.is_variant_applied}));
this.$buttonsPanel.find('.o_mrp_bom_print').on('click', this._onClickPrint.bind(this));
@@ -48,10 +48,14 @@ var stock_report_generic = AbstractAction.extend({
});
},
start: async function() {
this.controlPanelProps.cp_content = { $buttons: this.$buttons };
const props = this.getControlPanelProps();
this.controlPanelProps.cp_content = props;
await this._super(...arguments);
this.set_html();
},
getControlPanelProps: function() {
return { $buttons: this.$buttons }
},
// Fetches the html and is previous report.context if any, else create it
get_html: async function() {
const { html } = await this._rpc({