Skip to content

Commit

Permalink
[FIX] stock_account: Invalid product price history breaks stock valua…
Browse files Browse the repository at this point in the history
…tion

Steps to reproduce:

1. Create a new Stockable Product
2. Set cost price to 2.00
3. Adjust stock to 10 pcs
4. Enable developer mode
5. Go to Inventory > Reports > Inventory at Date
6. Select current time and retrieve the inventory value

Bug:

The stock valuation for the product was 0.0.

Reason:

When creating a stockable product, Odoo creates
two price history entries with the same datetime
but different cost. The stock valuation report only
takes one of them into account.

Fixes odoo#14889

opw:747857
  • Loading branch information
simongoffin committed Jun 26, 2017
1 parent aaadb23 commit 51d072d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/stock_account/report/stock_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=Fals
self._cr.execute("""SELECT DISTINCT ON (product_id, company_id) product_id, company_id, cost
FROM product_price_history
WHERE product_id in %s AND datetime <= %s
ORDER BY product_id, company_id, datetime DESC""", (tuple(not_real_cost_method_products.ids), date))
ORDER BY product_id, company_id, datetime DESC, id DESC""", (tuple(not_real_cost_method_products.ids), date))
for history in self._cr.dictfetchall():
histories_dict[(history['product_id'], history['company_id'])] = history['cost']

Expand Down

0 comments on commit 51d072d

Please sign in to comment.