From efbe15bfb34d353fc97180c5257d933b64549c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 8 Mar 2017 10:46:46 +0100 Subject: [PATCH] Use Function field to compute drop_shipment visibility drop_shipment should not be visible for service products. issue6293 review30041002 --- purchase.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/purchase.py b/purchase.py index f808dea61b..f54ca013a0 100644 --- a/purchase.py +++ b/purchase.py @@ -147,9 +147,18 @@ class ProductSupplier: drop_shipment = fields.Boolean('Drop Shipment', states={ - 'invisible': ~Eval('_parent_product', {}).get('supply_on_sale', - False), - }) + 'invisible': ~Eval('drop_shipment_available', False), + }, + depends=['drop_shipment_available']) + drop_shipment_available = fields.Function( + fields.Boolean("Drop Shipment Available"), + 'on_change_with_drop_shipment_available') + + @fields.depends('product', + '_parent_product.type', '_parent_product.supply_on_sale') + def on_change_with_drop_shipment_available(self, name=None): + if self.product and self.product.type in {'goods', 'assets'}: + return self.product.supply_on_sale class CreatePurchase: