average price computation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
New
|
Undecided
|
Unassigned |
Bug Description
This affects both V6 and V7
stock/stock.py - do_partial - average price computation
The first if statement limits the average price computation to a pcik type of 'in'.
This means that a stock return for a purchase does not update average cost.
For example:
Receive 10 @ 20.00 SOH = 10 Avg Cost = $20.00 Value 200.00
Receive 10 @ 15.00 SOH = 20 Avg Cost = $17.50 Value 350.00
Return to Supplier
Per curr logic: 5 @ $20.00 SOH = 15 Avg Cost = $17.50
Should be: 5 @ $20.00 SOH = 15 Avg Cost = $ 16.67
Note - the return is correctly picking up the cost from the inwards move, so does that outwards move (ie the return) at the cost applicable for the receipt. Howver line 1256 means that this move is not catered for in the average cost computation
I suggest the following logic:
if pick.purchase_id and move.product_
if pick.type == 'in'
[do as per current]
else
[similar logic except is an out not an in for qty calculations]
NOTE: I have checked the sale returns logic. The cost of the return move uses the current average cost of the product rather than the cost of the orinal move. While this is technically incorrect, both the average cost and the journal entries created align, so at least it doesn't make an immediate error. Ideally, the sale return move should use the cost from the original sale move, in which case the average cost will need to be recalculated as well.
also, new_price is calculated by two different formula in subsequqnt lines of code - presumably the second claculation overwrites the first, so why is the first calcuation even there?