[MIG] account_financial_report: Migration to 16.0
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
// Method is available here https://github.com/odoo/odoo/blob/15.0/addons/web/static/src/webclient/actions/action_service.js#L981
|
||||
// TO DO: Check for implement this action inherit
|
||||
// odoo.define("account_financial_report.ReportActionManager", function (require) {
|
||||
// "use strict";
|
||||
//
|
||||
// const ActionManager = require("web.ActionManager");
|
||||
// require("web.ReportActionManager");
|
||||
//
|
||||
// ActionManager.include({
|
||||
// /**
|
||||
// * @override
|
||||
// */
|
||||
// _executeReportClientAction: function (action, options) {
|
||||
// const MODULE_NAME = "account_financial_report";
|
||||
//
|
||||
// // When 'report_action' is called from the backend, Odoo hardcodes the action tag.
|
||||
// // We have to make a hack to use our own report controller.
|
||||
// if (action.report_name.startsWith(`${MODULE_NAME}.`)) {
|
||||
// const urls = this._makeReportUrls(action);
|
||||
// const clientActionOptions = _.extend({}, options, {
|
||||
// context: action.context,
|
||||
// data: action.data,
|
||||
// display_name: action.display_name,
|
||||
// name: action.name,
|
||||
// report_file: action.report_file,
|
||||
// report_name: action.report_name,
|
||||
// report_url: urls.html,
|
||||
// });
|
||||
// return this.doAction(
|
||||
// "account_financial_report.client_action",
|
||||
// clientActionOptions
|
||||
// );
|
||||
// }
|
||||
// return this._super.apply(this, arguments);
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
@@ -1,58 +0,0 @@
|
||||
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.controlPanelProps.cp_content = {
|
||||
$buttons: this.$buttons,
|
||||
};
|
||||
|
||||
this._controlPanelWrapper.update(this.controlPanelProps);
|
||||
});
|
||||
},
|
||||
|
||||
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) {
|
||||
if (!_.isString(str)) {
|
||||
return 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;
|
||||
});
|
||||
38
account_financial_report/static/src/js/report_action.esm.js
Normal file
38
account_financial_report/static/src/js/report_action.esm.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/** @odoo-module **/
|
||||
import {ReportAction} from "@web/webclient/actions/reports/report_action";
|
||||
import {patch} from "web.utils";
|
||||
|
||||
const MODULE_NAME = "account_financial_report";
|
||||
|
||||
patch(ReportAction.prototype, "account_financial_report.ReportAction", {
|
||||
setup() {
|
||||
this._super.apply(this, arguments);
|
||||
this.isAccountFinancialReport = this.props.report_name.startsWith(
|
||||
`${MODULE_NAME}.`
|
||||
);
|
||||
},
|
||||
|
||||
export() {
|
||||
this.action.doAction({
|
||||
type: "ir.actions.report",
|
||||
report_type: "xlsx",
|
||||
report_name: this._get_xlsx_name(this.props.report_name),
|
||||
report_file: this._get_xlsx_name(this.props.report_file),
|
||||
data: this.props.data || {},
|
||||
context: this.props.context || {},
|
||||
display_name: this.title,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} str
|
||||
* @returns {String}
|
||||
*/
|
||||
_get_xlsx_name(str) {
|
||||
if (!_.isString(str)) {
|
||||
return str;
|
||||
}
|
||||
const parts = str.split(".");
|
||||
return `a_f_r.report_${parts[parts.length - 1]}_xlsx`;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user