From cacc5423f6c0277ef23f9ef7e1d5059018a7841e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 20 Jan 2015 11:44:13 +0100 Subject: [PATCH] Reset the printer's tray when the printer is changed --- printer_tray/ir_report.py | 7 ++++++- printer_tray/report_xml_action.py | 5 +++++ printer_tray/users.py | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/printer_tray/ir_report.py b/printer_tray/ir_report.py index 9b36724..fb77593 100644 --- a/printer_tray/ir_report.py +++ b/printer_tray/ir_report.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp import models, fields +from openerp import models, fields, api class IrActionsReportXml(models.Model): @@ -30,3 +30,8 @@ class IrActionsReportXml(models.Model): string='Paper Source', domain="[('printer_id', '=', printing_printer_id)]", ) + + @api.onchange('printing_printer_id') + def onchange_printing_printer_id(self): + """ Reset the tray when the printer is changed """ + self.printer_tray_id = False diff --git a/printer_tray/report_xml_action.py b/printer_tray/report_xml_action.py index 0e29524..5056150 100644 --- a/printer_tray/report_xml_action.py +++ b/printer_tray/report_xml_action.py @@ -37,3 +37,8 @@ class ReportXMLAction(models.Model): res = super(ReportXMLAction, self).behaviour() res['tray'] = self.printer_tray_id.system_name return res + + @api.onchange('printer_id') + def onchange_printer_id(self): + """ Reset the tray when the printer is changed """ + self.printer_tray_id = False diff --git a/printer_tray/users.py b/printer_tray/users.py index 57d1276..47d7faa 100644 --- a/printer_tray/users.py +++ b/printer_tray/users.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp import models, fields +from openerp import models, fields, api class ResUsers(models.Model): @@ -30,3 +30,8 @@ class ResUsers(models.Model): string='Default Printer Paper Source', domain="[('printer_id', '=', printing_printer_id)]", ) + + @api.onchange('printing_printer_id') + def onchange_printing_printer_id(self): + """ Reset the tray when the printer is changed """ + self.printer_tray_id = False