mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[WIP] Migrate base_report_to_printer to V12
This commit is contained in:
committed by
David Montull
parent
dbb332b204
commit
2dfca7adeb
@@ -1,48 +1,50 @@
|
||||
odoo.define('base_report_to_printer.print', function(require) {
|
||||
odoo.define('base_report_to_printer.print', function (require) {
|
||||
'use strict';
|
||||
|
||||
var ActionManager = require('web.ActionManager');
|
||||
var core = require('web.core');
|
||||
var framework = require('web.framework');
|
||||
var rpc = require('web.rpc');
|
||||
var _t = core._t;
|
||||
|
||||
ActionManager.include({
|
||||
ir_actions_report: function(action, options) {
|
||||
action_val = _.clone(action);
|
||||
var _t = core._t;
|
||||
_triggerDownload: function (action, options, type) {
|
||||
var self = this;
|
||||
var _super = this._super;
|
||||
|
||||
if (action_val.report_type === 'qweb-pdf') {
|
||||
framework.blockUI();
|
||||
rpc.query({
|
||||
if (type === 'pdf') {
|
||||
this._rpc({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_action_for_report_name',
|
||||
args: [action_val.report_name]
|
||||
args: [action.report_name],
|
||||
}).then(function (print_action) {
|
||||
if (print_action && print_action.action === 'server') {
|
||||
framework.unblockUI();
|
||||
rpc.query({
|
||||
self._rpc({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_document',
|
||||
args: [action_val.id, action_val.context.active_ids],
|
||||
kwargs: {data: action_val.data || {}},
|
||||
context: action_val.context || {}
|
||||
args: [action.id, action.context.active_ids],
|
||||
kwargs: {data: action.data || {}},
|
||||
context: action.context || {},
|
||||
}).then(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_.str.sprintf(_t('Document sent to the printer %s'), print_action.printer_name));
|
||||
_.str.sprintf(
|
||||
_t('Document sent to the printer %s'),
|
||||
print_action.printer_name
|
||||
)
|
||||
);
|
||||
}).fail(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_.str.sprintf(_t('Error when sending the document to the printer '), print_action.printer_name));
|
||||
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
});
|
||||
_.str.sprintf(
|
||||
_t('Error when sending the document to the printer '),
|
||||
print_action.printer_name
|
||||
)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action, options, type]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
return _super.apply(self, [action, options, type]);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user