From 9c2536bc8a256ef8e1ed9da9793c58f7f104efcf Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 18 Jul 2013 13:59:34 +0200 Subject: [PATCH] [WIP] Add domain on requested products in _product_available bzr revid: jco@openerp.com-20130718115934-h0nb53e9xd74opju --- addons/stock/product.py | 10 +++++++--- addons/stock/report/report_stock_move.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index dec76623ce4..fbd8c21d88b 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -111,21 +111,25 @@ class product_product(osv.osv): context = context or {} field_names = field_names or [] + domain_products = [('product_id', 'in', ids)] domain_quant, domain_move_in, domain_move_out = self._get_domain_locations(cr, uid, ids, context=context) - domain_move_in += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))] - domain_move_out += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))] + domain_move_in += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))] + domain_products + domain_move_out += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))] + domain_products + domain_quant += domain_products if context.get('lot_id', False): - domain_quants.append(('lot_id','=',context['lot_id'])) + domain_quant.append(('lot_id','=',context['lot_id'])) moves_in = [] moves_out = [] else: +# if field_names in ['incoming_qty', 'outgoing_qty', 'virtual_available']: moves_in = self.pool.get('stock.move').read_group(cr, uid, domain_move_in, ['product_id', 'product_qty'], ['product_id'], context=context) moves_out = self.pool.get('stock.move').read_group(cr, uid, domain_move_out, ['product_id', 'product_qty'], ['product_id'], context=context) quants = self.pool.get('stock.quant').read_group(cr, uid, domain_quant, ['product_id', 'qty'], ['product_id'], context=context) quants = dict(map(lambda x: (x['product_id'][0], x['qty']), quants)) + moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in)) moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out)) diff --git a/addons/stock/report/report_stock_move.py b/addons/stock/report/report_stock_move.py index 05987e18b7e..7d5de27b537 100644 --- a/addons/stock/report/report_stock_move.py +++ b/addons/stock/report/report_stock_move.py @@ -58,7 +58,7 @@ class report_stock_inventory(osv.osv): prods = product_obj.browse(cr, uid, proddict[prodelem].keys(), context=ctx) for prod in prods: prodbrow[(prodelem, prod.id)] = prod - # use prodbrow and exisiting value on the report lines to calculate the inventory_value on the report lines + # use prodbrow and existing value on the report lines to calculate the inventory_value on the report lines for line in lines: ctx = context.copy() ctx['force_company'] = line.company_id.id