mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
printer_tray: Allow to call print_option with no report
This commit is contained in:
committed by
Graeme Gellatly
parent
c59f9d6dd0
commit
e11cf228f1
@@ -67,27 +67,29 @@ class PrintingPrinter(models.Model):
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def print_options(self, report, format, copies=1):
|
||||
def print_options(self, report=None, format=None, copies=1):
|
||||
""" Hook to define Tray """
|
||||
printing_act_obj = self.env['printing.report.xml.action']
|
||||
options = super(PrintingPrinter, self).print_options(report, format)
|
||||
|
||||
# Retrieve user default values
|
||||
user = self.env.user
|
||||
tray = user.printer_tray_id
|
||||
tray = self.env.user.printer_tray_id
|
||||
|
||||
# Retrieve report default values
|
||||
if report.printer_tray_id:
|
||||
tray = report.printer_tray_id
|
||||
if report is not None:
|
||||
# Retrieve report default values
|
||||
if report.printer_tray_id:
|
||||
tray = report.printer_tray_id
|
||||
|
||||
# Retrieve report-user specific values
|
||||
action = printing_act_obj.search([('report_id', '=', report.id),
|
||||
('user_id', '=', self.env.uid),
|
||||
('action', '!=', 'user_default')],
|
||||
limit=1)
|
||||
if action.printer_tray_id:
|
||||
tray = action.printer_tray_id
|
||||
# Retrieve report-user specific values
|
||||
action = printing_act_obj.search([
|
||||
('report_id', '=', report.id),
|
||||
('user_id', '=', self.env.uid),
|
||||
('action', '!=', 'user_default'),
|
||||
], limit=1)
|
||||
if action.printer_tray_id:
|
||||
tray = action.printer_tray_id
|
||||
|
||||
if tray:
|
||||
options['InputSlot'] = str(tray.system_name)
|
||||
|
||||
if tray:
|
||||
options['InputSlot'] = str(tray.system_name)
|
||||
return options
|
||||
|
||||
@@ -113,6 +113,11 @@ class TestPrintingPrinter(TransactionCase):
|
||||
'system_name': 'Action tray',
|
||||
})
|
||||
|
||||
# No report passed
|
||||
self.env.user.printer_tray_id = False
|
||||
options = self.Model.print_options()
|
||||
self.assertFalse('InputSlot' in options)
|
||||
|
||||
# No tray defined
|
||||
self.env.user.printer_tray_id = False
|
||||
report.printer_tray_id = False
|
||||
|
||||
Reference in New Issue
Block a user