I need to add a new button to the header panel of my report, but it’s not working. The following code allows the module to update without errors, but when I look at the report page, it gets completely stuck; it remains blank and doesn’t throw any errors. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="stock_button_report.ListView.Buttons" t-inherit="web.ListView">
<xpath expr="//t[@t-set-slot='control-panel-additional-actions']" position="after">
<button type="button" class="btn btn-primary" style="margin-left: 10px;"
t-on-click="OnTestClick">
Example
</button>
</xpath>
</t>
</templates>
JS
/** @odoo-module */
import { ListController } from "@web/views/list/list_controller";
import { registry } from "@web/core/registry";
import { listView } from "@web/views/list/list_view";
export class StockButtonListController extends ListController {
setup() {
super.setup();
}
OnTestClick() {}
}
registry.category("views").add("stock_button_report", {
...listView,
Controller: StockButtonListController,
buttonTemplate: "stock_button_report.ListView.Buttons",
});
View
<record id="view_report_history_tree" model="ir.ui.view">
<field name="name">report.history.tree</field>
<field name="model">report.history</field>
<field name="arch" type="xml">
<tree string="Historial de Informes">
<!-- <header>
<button name="action_for_wizard" string="Action" object="action" />
</header> -->
<field name="name" />
<field name="create_date" />
<field name="user_id" />
<field name="file_name" />
<button name="action_download_report" type="object" icon="fa-download"
string="Descargar" />
</tree>
</field>
</record>
<record id="view_grouped_stock_moves_inherited_tree" model="ir.ui.view">
<field name="name">report.history.tree.inherit</field>
<field name="model">report.history</field>
<field name="inherit_id" ref="view_report_history_tree" />
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="js_class">stock_button_report</attribute>
</xpath>
</field>
</record>
Thanks for the help