mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[FIX] test if the module is installed before monkey patching
This commit is contained in:
@@ -45,41 +45,44 @@ original_exp_report_get = openerp.service.report.exp_report_get
|
|||||||
|
|
||||||
|
|
||||||
def exp_report_get(db, uid, report_id):
|
def exp_report_get(db, uid, report_id):
|
||||||
|
# First we need to know if the module is installed
|
||||||
registry = openerp.registry(db)
|
registry = openerp.registry(db)
|
||||||
cr = registry.cursor()
|
if registry.get('printing.printer'):
|
||||||
try:
|
cr = registry.cursor()
|
||||||
# First of all load report defaults: name, action and printer
|
try:
|
||||||
report_obj = registry['ir.actions.report.xml']
|
# First of all load report defaults: name, action and printer
|
||||||
report_name = self_reports[report_id]['report_name']
|
report_obj = registry['ir.actions.report.xml']
|
||||||
report = report_obj.search(cr, uid,
|
report_name = self_reports[report_id]['report_name']
|
||||||
[('report_name', '=', report_name)])
|
report = report_obj.search(cr, uid,
|
||||||
if report:
|
[('report_name', '=', report_name)])
|
||||||
report = report_obj.browse(cr, uid, report[0])
|
if report:
|
||||||
data = report.behaviour()[report.id]
|
report = report_obj.browse(cr, uid, report[0])
|
||||||
action = data['action']
|
data = report.behaviour()[report.id]
|
||||||
printer = data['printer']
|
action = data['action']
|
||||||
if action != 'client':
|
printer = data['printer']
|
||||||
if (self_reports and self_reports.get(report_id)
|
if action != 'client':
|
||||||
and self_reports[report_id].get('result')
|
if (self_reports and self_reports.get(report_id)
|
||||||
and self_reports[report_id].get('format')):
|
and self_reports[report_id].get('result')
|
||||||
printer.print_document(report,
|
and self_reports[report_id].get('format')):
|
||||||
self_reports[report_id]['result'],
|
printer.print_document(report,
|
||||||
self_reports[report_id]['format'])
|
self_reports
|
||||||
# FIXME "Warning" removed as it breaks the workflow
|
[report_id]['result'],
|
||||||
# it would be interesting to have a dialog box to
|
self_reports
|
||||||
# confirm if we really want to print in this case it
|
[report_id]['format'])
|
||||||
# must be with a by pass parameter to allow massive
|
# FIXME "Warning" removed as it breaks the workflow
|
||||||
# prints
|
# it would be interesting to have a dialog box to
|
||||||
# raise osv.except_osv(
|
# confirm if we really want to print in this case it
|
||||||
# _('Printing...'),
|
# must be with a by pass parameter to allow massive
|
||||||
# _('Document sent to printer %s') % (printer,))
|
# prints
|
||||||
|
# raise osv.except_osv(
|
||||||
except:
|
# _('Printing...'),
|
||||||
cr.rollback()
|
# _('Document sent to printer %s') % (printer,))
|
||||||
raise
|
|
||||||
finally:
|
|
||||||
cr.close()
|
|
||||||
|
|
||||||
|
except:
|
||||||
|
cr.rollback()
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
cr.close()
|
||||||
return original_exp_report_get(db, uid, report_id)
|
return original_exp_report_get(db, uid, report_id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user