From f2d62ab2a46a4b6f70834c5efc5a2776c2acec65 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 29 Jan 2014 15:00:05 +0100 Subject: [PATCH] [FIX]stock_warehouse: raise of error for default_resupply_id != warehouse_id should not be in a sql_constraint since it will not rollback the creation of routes. lp bug: https://launchpad.net/bugs/1273591 fixed bzr revid: csn@openerp.com-20140129140005-efomi7gdmcf1pi1q --- addons/stock/stock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 899d253e70c..c0ae91602ea 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2438,7 +2438,6 @@ class stock_warehouse(osv.osv): _sql_constraints = [ ('warehouse_name_uniq', 'unique(name, company_id)', 'The name of the warehouse must be unique per company!'), ('warehouse_code_uniq', 'unique(code, company_id)', 'The code of the warehouse must be unique per company!'), - ('default_resupply_wh_diff', 'check (id != default_resupply_wh_id)', 'The default resupply warehouse should be different that the warehouse itself!'), ] def _get_partner_locations(self, cr, uid, ids, context=None): @@ -2903,6 +2902,8 @@ class stock_warehouse(osv.osv): #not implemented pass if 'default_resupply_wh_id' in vals: + if vals.get('default_resupply_wh_id') == warehouse.id: + raise osv.except_osv(_('Warning'),_('The default resupply warehouse should be different that the warehouse itself!')) if warehouse.default_resupply_wh_id: #remove the existing resupplying route on all products to_remove_route_ids = route_obj.search(cr, uid, [('supplied_wh_id', '=', warehouse.id), ('supplier_wh_id', '=', warehouse.default_resupply_wh_id.id)], context=context)