forked from OCA/report-print-send
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do no longer returns a PDF when a report is printed
Instead, a notification is displayed to the user. When report.get_pdf() is called on a report that must be printer, it will print the report *and* returns the pdf, thus code that calls directly report.get_pdf() will print the pdf on the printer as expected. Fixes OCA#16
- Loading branch information
1 parent
9f7329c
commit 477ba60
Showing
5 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<template id="assets_backend" name="base_report_to_printer assets" inherit_id="report.assets_backend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/base_report_to_printer/static/src/js/qwebactionmanager.js"></script> | ||
</xpath> | ||
</template> | ||
</data> | ||
</openerp> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
openerp.base_report_to_printer = function(instance) { | ||
|
||
instance.web.ActionManager.include({ | ||
ir_actions_report_xml: function(action, options) { | ||
instance.web.blockUI(); | ||
action = _.clone(action); | ||
var _t = instance.web._t; | ||
var self = this; | ||
var _super = this._super; | ||
|
||
if ('report_type' in action && action.report_type === 'qweb-pdf') { | ||
new instance.web.Model('ir.actions.report.xml') | ||
.call('print_action_for_report_name', [action.report_name]) | ||
.then(function(print_action){ | ||
if (print_action && print_action['action'] === 'server') { | ||
instance.web.unblockUI(); | ||
new instance.web.Model('report') | ||
.call('print_document', | ||
[action.context.active_ids, | ||
action.report_name, | ||
], | ||
{data: action.data || {}, | ||
context: action.context || {}, | ||
}) | ||
.then(function(result){ | ||
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, options]); | ||
} | ||
}); | ||
} else { | ||
return _super.apply(self, [action, options]); | ||
} | ||
} | ||
}); | ||
}; | ||
|