From 1ca3b3df3421961caec3b747a364071c80f5c7da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 17:14:58 +0700 Subject: initial commit --- .../static/src/js/action_manager.js | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 account_reports_xlsx/static/src/js/action_manager.js (limited to 'account_reports_xlsx/static/src') diff --git a/account_reports_xlsx/static/src/js/action_manager.js b/account_reports_xlsx/static/src/js/action_manager.js new file mode 100644 index 0000000..15ef8d3 --- /dev/null +++ b/account_reports_xlsx/static/src/js/action_manager.js @@ -0,0 +1,52 @@ +odoo.define('account_reports_xlsx.ActionManager', function (require) { +"use strict"; + +/** + * The purpose of this file is to add the actions of type + * 'ir_actions_xlsx_download' to the ActionManager. + */ + +var ActionManager = require('web.ActionManager'); +var framework = require('web.framework'); +var session = require('web.session'); + +ActionManager.include({ + + /** + * Executes actions of type 'ir_actions_xlsx_download'. + * + * @private + * @param {Object} action the description of the action to execute + * @returns {Deferred} resolved when the report has been downloaded ; + * rejected if an error occurred during the report generation + */ + _executexlsxReportDownloadAction: function (action) { + console.log("ExecutexlsxReportDownloadAction") + console.log(action) + framework.blockUI(); + var def = $.Deferred(); + session.get_file({ + url: '/xlsx_reports', + data: action.data, + success: def.resolve.bind(def), + error: (error) => this.call('crash_manager', 'rpc_error', error), + complete: framework.unblockUI, + }); + return def; + }, + /** + * Overrides to handle the 'ir_actions_xlsx_download' actions. + * + * @override + * @private + */ + _executeReportAction: function (action, options) { + console.log("inside Execute report action") + if (action.report_type === 'xlsx') { + return this._executexlsxReportDownloadAction(action, options); + } + return this._super.apply(this, arguments); + }, +}); + +}); -- cgit v1.2.3