From b9d4976a97c6e121b31906a09bd0cd0d3fb932ae Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Thu, 29 Oct 2020 10:15:19 +0000 Subject: [PATCH] [FIX] pos_epson_printer: disable cashdrawer when parent option is unchecked Open POS Config Enable the option 'Connect Devices' In 'Epson Receipt Printer IP Address' write anything then focus out Enable the 'Cashdrawer' Option Empty 'Epson Receipt Printer IP Address' Disable'Connect Devices' Save Blanking 'Epson Receipt Printer IP Address' leaving 'Cashdrawer' on will lead to crash during the payment session if the user click on 'Open Cashbox' when using cash as a payment method. 'Cashdrawer' should be disabled automatically when needed. opw-2367498 closes odoo/odoo#61086 X-original-commit: 6491f9b20570c374e464194cbce698b00c173847 Signed-off-by: agr-odoo --- addons/pos_epson_printer/models/pos_config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/pos_epson_printer/models/pos_config.py b/addons/pos_epson_printer/models/pos_config.py index 885d9e4d70f..8fe6df3ad0b 100644 --- a/addons/pos_epson_printer/models/pos_config.py +++ b/addons/pos_epson_printer/models/pos_config.py @@ -1,9 +1,14 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class PosConfig(models.Model): _inherit = 'pos.config' epson_printer_ip = fields.Char(string='Epson Printer IP', help="Local IP address of an Epson receipt printer.") + + @api.onchange('epson_printer_ip') + def _onchange_epson_printer_ip(self): + if self.epson_printer_ip in (False, ''): + self.iface_cashdrawer = False