You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.6 KiB

odoo.define("account_financial_report.client_action", function(require) {
"use strict";
var ReportAction = require("report.client_action");
var core = require("web.core");
var QWeb = core.qweb;
const AFRReportAction = ReportAction.extend({
start: function() {
return this._super.apply(this, arguments).then(() => {
this.$buttons = $(
QWeb.render(
"account_financial_report.client_action.ControlButtons",
{}
)
);
this.$buttons.on("click", ".o_report_print", this.on_click_print);
this.$buttons.on("click", ".o_report_export", this.on_click_export);
this._update_control_panel();
});
},
on_click_export: function() {
const action = {
type: "ir.actions.report",
report_type: "xlsx",
report_name: this._get_xlsx_name(this.report_name),
report_file: this._get_xlsx_name(this.report_file),
data: this.data,
context: this.context,
display_name: this.title,
};
return this.do_action(action);
},
/**
* @param {String} str
* @returns {String}
*/
_get_xlsx_name: function(str) {
const parts = str.split(".");
return `a_f_r.report_${parts[parts.length - 1]}_xlsx`;
},
});
core.action_registry.add("account_financial_report.client_action", AFRReportAction);
return AFRReportAction;
});