From 74e054201b05d6486b4165f9983d6bf6bf362d71 Mon Sep 17 00:00:00 2001 From: "Ravi Gohil (OpenERP)" Date: Wed, 18 Sep 2013 14:32:44 +0530 Subject: [PATCH] [FIX] procurement: User belonging to the company other then the 'Your Company' would not be able to create record for object 'stock.warehouse.orderpoint'(Warehouse/Configuration/Reordering Rules) as it tries to get the default warehouse using xml_id(warehouse0) that does not belong to current user's company : (Maintenance Case : 596679) lp bug: https://launchpad.net/bugs/1212429 fixed bzr revid: rgo@tinyerp.com-20130918090244-edabc3uq6mfmx7vu --- addons/procurement/procurement.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 8a5b5107319..9879b91e88b 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -547,14 +547,14 @@ class stock_warehouse_orderpoint(osv.osv): ] def default_get(self, cr, uid, fields, context=None): + warehouse_obj = self.pool.get('stock.warehouse') res = super(stock_warehouse_orderpoint, self).default_get(cr, uid, fields, context) # default 'warehouse_id' and 'location_id' if 'warehouse_id' not in res: - warehouse = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'warehouse0', context) - res['warehouse_id'] = warehouse.id + warehouse_ids = warehouse_obj.search(cr, uid, [('company_id', '=', res.get('company_id'))], context=context) + res['warehouse_id'] = warehouse_ids and warehouse_ids[0] or False if 'location_id' not in res: - warehouse = self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context) - res['location_id'] = warehouse.lot_stock_id.id + res['location_id'] = False if not res.get('warehouse_id') else self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context).lot_stock_id.id return res def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context=None):