[WIP] Migrate base_report_to_printer to V12

This commit is contained in:
Graeme Gellatly
2019-01-31 12:40:08 +13:00
committed by David Montull
parent dbb332b204
commit 2dfca7adeb
63 changed files with 4131 additions and 3513 deletions

View File

@@ -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]);
}
}
},
});
});