Skip to content
Snippets Groups Projects
Commit febe8739 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd) Committed by Djamel Touati
Browse files

[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: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 35ca91fe
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment