[FIX] stock_account: stock valuation report without result

This is related to rev. 55b7f15ee2

Prevent crash when there is no line to display
in the stock valuation report
Reporting > Warehouse > Stock Valuation.

Like when there is not yet any data, or the filter gives no result

opw-643748
This commit is contained in:
Denis Ledoux 2015-07-01 15:55:28 +02:00
parent 49f2514a9d
commit bdf980e4b4
1 changed files with 4 additions and 2 deletions

View File

@ -56,8 +56,10 @@ class stock_history(osv.osv):
for product_id in ids:
line_ids.add(product_id)
line_ids = list(line_ids)
cr.execute('SELECT id, product_id, price_unit_on_quant, company_id, quantity FROM stock_history WHERE id in %s', (tuple(line_ids),))
lines_rec = cr.dictfetchall()
lines_rec = {}
if line_ids:
cr.execute('SELECT id, product_id, price_unit_on_quant, company_id, quantity FROM stock_history WHERE id in %s', (tuple(line_ids),))
lines_rec = cr.dictfetchall()
lines_dict = dict((line['id'], line) for line in lines_rec)
product_ids = list(set(line_rec['product_id'] for line_rec in lines_rec))
products_rec = self.pool['product.product'].read(cr, uid, product_ids, ['cost_method', 'product_tmpl_id'], context=context)