From fa449aafd90bf356d82ad37170120d610d47bf1b Mon Sep 17 00:00:00 2001 From: Mario Puntin Date: Tue, 17 Nov 2015 18:05:50 -0300 Subject: [PATCH] Prevent deleting product and unit linked to purchase lines issue4894 review20541002 --- purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/purchase.py b/purchase.py index 6d29b914a3..25171f3a9a 100644 --- a/purchase.py +++ b/purchase.py @@ -878,6 +878,7 @@ class PurchaseLine(ModelSQL, ModelView): }, depends=['unit_digits', 'type']) unit = fields.Many2One('product.uom', 'Unit', + ondelete='RESTRICT', states={ 'required': Bool(Eval('product')), 'invisible': Eval('type') != 'line', @@ -892,7 +893,7 @@ class PurchaseLine(ModelSQL, ModelView): unit_digits = fields.Function(fields.Integer('Unit Digits'), 'on_change_with_unit_digits') product = fields.Many2One('product.product', 'Product', - domain=[('purchasable', '=', True)], + ondelete='RESTRICT', domain=[('purchasable', '=', True)], states={ 'invisible': Eval('type') != 'line', 'readonly': ~Eval('_parent_purchase'),