From d45e933a89cb823670d0daa91a4fab2a0ddf99aa Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Fri, 12 Jan 2024 12:25:32 +0100 Subject: [PATCH] [FIX] point_of_sale: Correctly delete linked pos_printer to iot_box Current behavior: You couldn't delete an iot_box if a pos_printer was linked to it. You always get a validation error saying that "Proxy IP cannot be empty" To fix this we first want to check that the device_id linked to the printer still exists. To do this we need to move the constraint to the pos_iot module (because the device_id field is defined there) Steps to reproduce: - Install pos_iot - Activate preparation printer in POS - Create a printer and link it to an iot_box device - Try to delete the iot_box opw-3597370 closes odoo/odoo#150502 X-original-commit: 7b41e51043c1f80971f6cc698876f8bda35f07ef Related: odoo/enterprise#54874 Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/models/pos_printer.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/point_of_sale/models/pos_printer.py b/addons/point_of_sale/models/pos_printer.py index c9d6c182c5c..a923696d3f2 100644 --- a/addons/point_of_sale/models/pos_printer.py +++ b/addons/point_of_sale/models/pos_printer.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, api, _ -from odoo.exceptions import ValidationError +from odoo import fields, models class PosPrinter(models.Model): @@ -14,9 +13,3 @@ class PosPrinter(models.Model): selection=[('iot', ' Use a printer connected to the IoT Box')]) proxy_ip = fields.Char('Proxy IP Address', help="The IP Address or hostname of the Printer's hardware proxy") product_categories_ids = fields.Many2many('pos.category', 'printer_category_rel', 'printer_id', 'category_id', string='Printed Product Categories') - - @api.constrains('proxy_ip') - def _constrains_proxy_ip(self): - for record in self: - if record.printer_type == 'iot' and not record.proxy_ip: - raise ValidationError(_("Proxy IP cannot be empty."))