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):