mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[PORT] Finalize move of printer_tray to base_report_to_printer,
fix tests as report param is not a string but recordset
This commit is contained in:
@@ -1,41 +1,46 @@
|
||||
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 Model = require('web.Model');
|
||||
var rpc = require('web.rpc');
|
||||
|
||||
|
||||
ActionManager.include({
|
||||
ir_actions_report: function(action, options) {
|
||||
action_val = _.clone(action);
|
||||
ir_actions_report: function (action, options) {
|
||||
var action_val = _.clone(action);
|
||||
var _t = core._t;
|
||||
var self = this;
|
||||
var _super = this._super;
|
||||
|
||||
if ('report_type' in action_val && action_val.report_type === 'qweb-pdf') {
|
||||
framework.blockUI();
|
||||
new Model('ir.actions.report').
|
||||
call('print_action_for_report_name', [action_val.report_name]).
|
||||
then(function(print_action){
|
||||
if (print_action && print_action.action_val === 'server') {
|
||||
framework.unblockUI();
|
||||
new Model('report').
|
||||
call('print_document',
|
||||
[action_val.context.active_ids, action_val.report_name],
|
||||
{data: action_val.data || {}, context: action_val.context || {}}).
|
||||
then(function(){
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Document sent to the printer ') + print_action.printer_name);
|
||||
}).fail(function() {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Error when sending the document to the printer ') + print_action.printer_name);
|
||||
rpc.query({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_action_for_report_name',
|
||||
args: [action_val.report_name]
|
||||
}).then(function (print_action) {
|
||||
if (print_action && print_action.action_val === 'server') {
|
||||
framework.unblockUI();
|
||||
rpc.query({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_document',
|
||||
args: [action_val.context.active_ids, action_val.report_name],
|
||||
kwargs: {data: action_val.data || {}},
|
||||
context: action_val.context || {}
|
||||
}).then(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Document sent to the printer ') + print_action.printer_name);
|
||||
}).fail(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Error when sending the document to the printer ') + print_action.printer_name);
|
||||
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user