summaryrefslogtreecommitdiff
path: root/account_reports_xlsx/static/src/js/action_manager.js
blob: 15ef8d3ef4b47eecfb541a55896fbe98fd6d60c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
    },
});

});