From c0e3024e46f1ada80ff430c7aad9aa4fac8260c1 Mon Sep 17 00:00:00 2001 From: sinergia Date: Wed, 9 Nov 2022 09:14:25 -0500 Subject: [PATCH] health register required in purchase --- purchase.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/purchase.py b/purchase.py index 3562507..12d02a9 100644 --- a/purchase.py +++ b/purchase.py @@ -87,7 +87,7 @@ class Line(metaclass=PoolMeta): product_equipment = fields.Boolean("Product Equipment", states={'readonly': True}) software_version = fields.Char("Software version") - health_register = fields.Char("Health Register") + health_register = fields.Char("Health Register", states={'required': Eval('product_equipment', True)}) @classmethod @@ -116,7 +116,13 @@ class Line(metaclass=PoolMeta): if self.unit_price: self.unit_price = round_price(self.unit_price) - + + @fields.depends('product', 'unit', 'purchase', + '_parent_purchase.party', '_parent_purchase.invoice_party', + 'product_supplier', 'product_equipment', + 'serial_equipment', 'software_version', + 'health_register', 'refurbish', methods=['compute_taxes', 'compute_unit_price', + '_get_product_supplier_pattern']) def on_change_product(self): if not self.product: self.product_equipment = False @@ -131,7 +137,6 @@ class Line(metaclass=PoolMeta): party = None if self.purchase: party = self.purchase.invoice_party or self.purchase.party - # Set taxes before unit_price to have taxes in context of purchase # price self.taxes = self.compute_taxes(party) @@ -155,6 +160,8 @@ class Line(metaclass=PoolMeta): if self.product.equipment: self.product_equipment = True self.address_equipment = self.default_address_equipment() + if self.product.software_required: + self.software_version = self.product.software_version @classmethod def view_attributes(cls):