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
|
return vals
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def print_options(self, report, format, copies=1):
|
def print_options(self, report=None, format=None, copies=1):
|
||||||
""" Hook to define Tray """
|
""" Hook to define Tray """
|
||||||
printing_act_obj = self.env['printing.report.xml.action']
|
printing_act_obj = self.env['printing.report.xml.action']
|
||||||
options = super(PrintingPrinter, self).print_options(report, format)
|
options = super(PrintingPrinter, self).print_options(report, format)
|
||||||
|
|
||||||
# Retrieve user default values
|
# Retrieve user default values
|
||||||
user = self.env.user
|
tray = self.env.user.printer_tray_id
|
||||||
tray = user.printer_tray_id
|
|
||||||
|
|
||||||
# Retrieve report default values
|
if report is not None:
|
||||||
if report.printer_tray_id:
|
# Retrieve report default values
|
||||||
tray = report.printer_tray_id
|
if report.printer_tray_id:
|
||||||
|
tray = report.printer_tray_id
|
||||||
|
|
||||||
# Retrieve report-user specific values
|
# Retrieve report-user specific values
|
||||||
action = printing_act_obj.search([('report_id', '=', report.id),
|
action = printing_act_obj.search([
|
||||||
('user_id', '=', self.env.uid),
|
('report_id', '=', report.id),
|
||||||
('action', '!=', 'user_default')],
|
('user_id', '=', self.env.uid),
|
||||||
limit=1)
|
('action', '!=', 'user_default'),
|
||||||
if action.printer_tray_id:
|
], limit=1)
|
||||||
tray = action.printer_tray_id
|
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
|
return options
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ class TestPrintingPrinter(TransactionCase):
|
|||||||
'system_name': 'Action tray',
|
'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
|
# No tray defined
|
||||||
self.env.user.printer_tray_id = False
|
self.env.user.printer_tray_id = False
|
||||||
report.printer_tray_id = False
|
report.printer_tray_id = False
|
||||||
|
|||||||
Reference in New Issue
Block a user