From 2d215db68618a5d17da054553777e16b3fcab956 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Tue, 13 Jan 2015 14:07:06 +0100 Subject: [PATCH] [FIX] stock_account: compute total inventory_value when no product is specified Without this fix, the 'Total' line of the pivot view does not display any inventory value, because there is no __domain as we are not asking the inventory value for any specific product. --- .../wizard/stock_valuation_history.py | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/addons/stock_account/wizard/stock_valuation_history.py b/addons/stock_account/wizard/stock_valuation_history.py index 06ef0aeefc9..193b19cbc7b 100644 --- a/addons/stock_account/wizard/stock_valuation_history.py +++ b/addons/stock_account/wizard/stock_valuation_history.py @@ -49,20 +49,19 @@ class stock_history(osv.osv): prod_dict = {} if 'inventory_value' in fields: for line in res: - if '__domain' in line: - lines = self.search(cr, uid, line['__domain'], context=context) - inv_value = 0.0 - product_tmpl_obj = self.pool.get("product.template") - lines_rec = self.browse(cr, uid, lines, context=context) - for line_rec in lines_rec: - if line_rec.product_id.cost_method == 'real': - price = line_rec.price_unit_on_quant - else: - if not line_rec.product_id.id in prod_dict: - prod_dict[line_rec.product_id.id] = product_tmpl_obj.get_history_price(cr, uid, line_rec.product_id.product_tmpl_id.id, line_rec.company_id.id, date=date, context=context) - price = prod_dict[line_rec.product_id.id] - inv_value += price * line_rec.quantity - line['inventory_value'] = inv_value + lines = self.search(cr, uid, line.get('__domain', []), context=context) + inv_value = 0.0 + product_tmpl_obj = self.pool.get("product.template") + lines_rec = self.browse(cr, uid, lines, context=context) + for line_rec in lines_rec: + if line_rec.product_id.cost_method == 'real': + price = line_rec.price_unit_on_quant + else: + if not line_rec.product_id.id in prod_dict: + prod_dict[line_rec.product_id.id] = product_tmpl_obj.get_history_price(cr, uid, line_rec.product_id.product_tmpl_id.id, line_rec.company_id.id, date=date, context=context) + price = prod_dict[line_rec.product_id.id] + inv_value += price * line_rec.quantity + line['inventory_value'] = inv_value return res def _get_inventory_value(self, cr, uid, ids, name, attr, context=None):