When get_pdf has no printer, just create the pdf file

And do not print anything, instead of raising an error.
This commit is contained in:
Guewen Baconnier
2015-01-26 11:55:26 +01:00
committed by Rod Schouteden
parent d49267ec8c
commit 4e7c38d68b
2 changed files with 10 additions and 10 deletions

View File

@@ -19,7 +19,7 @@
#
##############################################################################
from openerp import models
from openerp import models, exceptions, _
class Report(models.Model):
@@ -34,6 +34,10 @@ class Report(models.Model):
report = self._get_report_from_name(cr, uid, report_name)
behaviour = report.behaviour()[report.id]
printer = behaviour['printer']
if not printer:
raise exceptions.Warning(
_('No printer configured to print this report.')
)
return printer.print_document(report, document, report.report_type)
def get_pdf(self, cr, uid, ids, report_name, html=None,
@@ -48,7 +52,7 @@ class Report(models.Model):
context=context)
report = self._get_report_from_name(cr, uid, report_name)
behaviour = report.behaviour()[report.id]
if behaviour['action'] == 'server' and document:
printer = behaviour['printer']
printer = behaviour['printer']
if behaviour['action'] == 'server' and printer and document:
printer.print_document(report, document, report.report_type)
return document