You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] purchase_stock: inflated unit cost due to rounding method
Before this commit:
When calculating the `price_unit` for stock moves from purchase order lines,
the `remaining_qty` and `remaining_value` could be imprecise. Standard float
comparisons for these remaining amounts could lead to incorrect `price_unit`
calculations if, for example, `remaining_qty` was a very small float near zero.
This could result in inaccurate stock valuations, particularly when currency
conversions were involved or when landed costs were applied.
For example, 70.00000003 is rounded **up** to 70.00001 (with 5 digits),
resulting in a quantity difference of 0.00001, which incorrectly
inflates the unit cost.
After this commit:
Change the rounding method to 'HALF-UP' instead of the default 'UP' to improve
precise result for quantities.
Steps to reproduce:
1. Configure a product with AVCO real time. Set decimal precision for price
and UoM to 5 digits.
2. Create a Purchase Order (e.g., 190 units @ $110/unit).
3. Receive 70 units and create a backorder
4. Create and post a bill for the initially received quantity.
5. Apply a landed cost to the picking of the first 70 units.
6. Create a draft bill for the remaining quantity on the PO.
7. Receive the remaining 120 units from the backorder.
8. The product's cost explodes
opw-4705224
closesodoo#216661
X-original-commit: 7725b84
Signed-off-by: Tiffany Chang (tic) <[email protected]>
Signed-off-by: Walravens Mathieu (wama) <[email protected]>
0 commit comments