From bdf980e4b462d674b4e7bf647f526beb32a2ad07 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 1 Jul 2015 15:55:28 +0200 Subject: [PATCH] [FIX] stock_account: stock valuation report without result This is related to rev. 55b7f15ee2427e4c99edf05a5a61b069a5395bab 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 --- addons/stock_account/wizard/stock_valuation_history.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/wizard/stock_valuation_history.py b/addons/stock_account/wizard/stock_valuation_history.py index 66b670c2a75..13e35c7b91d 100644 --- a/addons/stock_account/wizard/stock_valuation_history.py +++ b/addons/stock_account/wizard/stock_valuation_history.py @@ -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)