From 7565cf79ea255f05862fe96b628806e81879e6be Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 12 Mar 2014 14:47:51 +0100 Subject: [PATCH] [FIX] stock: get only quants from your company. It means that when moving goods from company A to company B through a transit warehouse (without visibility on the other company), openerp will create a quant for company B instead of reusing the one from company A (which is the expected behavior as the history shouldn't be visible, the cost may be different...) bzr revid: qdp-launchpad@openerp.com-20140312134751-7384c3vm9wpg7htl --- addons/stock/stock.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 4e0ea982ac1..1e83b9d4dae 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -555,8 +555,14 @@ class stock_quant(osv.osv): ''' Implementation of removal strategies If it can not reserve, it will return a tuple (None, qty) ''' + if context is None: + context = {} domain += location and [('location_id', 'child_of', location.id)] or [] - domain += [('product_id', '=', product.id)] + domain + domain += [('product_id', '=', product.id)] + if context.get('force_company'): + domain += [('company_id', '=', context.get('force_company'))] + else: + domain += [('company_id', '=', self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id)] #don't take into account location that are production, supplier or inventory ignore_location_ids = self.pool.get('stock.location').search(cr, uid, [('usage', 'in', ('production', 'supplier', 'inventory'))], context=context) domain.append(('location_id','not in',ignore_location_ids))