Skip to content

Commit

Permalink
[FIX] stock_account: In stock valuation report, if all products real …
Browse files Browse the repository at this point in the history
…price, don't do the product history price query
  • Loading branch information
jco-odoo committed Jul 2, 2015
1 parent 49cc4b9 commit ce0027a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/stock_account/wizard/stock_valuation_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, con
products_rec = self.pool['product.product'].read(cr, uid, product_ids, ['cost_method', 'product_tmpl_id'], context=context)
products_dict = dict((product['id'], product) for product in products_rec)
cost_method_product_tmpl_ids = list(set(product['product_tmpl_id'][0] for product in products_rec if product['cost_method'] != 'real'))
cr.execute('SELECT DISTINCT ON (product_template_id, company_id) product_template_id, company_id, cost FROM product_price_history WHERE product_template_id in %s AND datetime <= %s ORDER BY product_template_id, company_id, datetime DESC', (tuple(cost_method_product_tmpl_ids), date))
histories = cr.dictfetchall()
histories = []
if cost_method_product_tmpl_ids:
cr.execute('SELECT DISTINCT ON (product_template_id, company_id) product_template_id, company_id, cost FROM product_price_history WHERE product_template_id in %s AND datetime <= %s ORDER BY product_template_id, company_id, datetime DESC', (tuple(cost_method_product_tmpl_ids), date))
histories = cr.dictfetchall()
histories_dict = {}
for history in histories:
histories_dict[(history['product_template_id'], history['company_id'])] = history['cost']
Expand Down

0 comments on commit ce0027a

Please sign in to comment.