-
- Downloads
[FIX] purchase: correctly calculate average price
cherry-pick of a4904fb4889c16322494981f5a1be586683704bd
Steps to reproduce the bug:
- Create a storable product “P1”
- costing method: avco
- Create a PO:
- Add the product “P1”:
- Line 1: Qty= 10, price= $50
- Line 2: Qty=1, price= $10
- Confirm the PO and receive the product
- Go to purchase → Reporting → Purchase Analysis
Problem:
The average price is incorrect, the current calculation is:
(50 + 10) / 2 = 30
The average should take into account the quantities purchased in each
line, And not simply the number of line, so the correct calculation
should be:
((10 * 50) + (10 * 1)) / 11 = 46.36
The SQL query is correct, it is when applying the read_group that the
calculation is incorrect, we should override it to make a personalized
calculation of the average.
opw-3136406
closes odoo/odoo#135267
Signed-off-by:
William Henrotin (whe) <whe@odoo.com>
Loading
Please register or sign in to comment