[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.
This commit is contained in:
parent
88ace35fa4
commit
2d215db686
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue