Skip to content
Snippets Groups Projects
Commit 5f8da70b authored by Adrien Widart (awt)'s avatar Adrien Widart (awt)
Browse files

[FIX] mrp: round the consumed quantity

To reproduce the issue:
1. In Settings, enable UoM
2. Edit the UoM 'Dozens':
    - Rounding: 1.0
3. Create two products P_finished, P_compo:
    - P_finished:
        - UoM: Dozens
4. Create a BoM:
    - Product: P_finished
    - Qty: 1 x Dozens
    - Compo: 1 x P_compo
5. Create and confirm a MO for 1 x P_finished
6. Edit the MO:
    - Set the producing qty to 1
    - Set the 'to consume' quantity of P_compo to 1.23

Error: the consumed quantity of P_compo is still 1.0 (it should be
1.23). If the user tries to set the quantity to 1.56, the consumed
quantity will become 2 (also incorrect, should be 1.56)

The UoM used to round the new consumed quantity of the component is
incorrect. Considering its definition:
https://github.com/odoo/odoo/blob/0fdd35cfb5c7145b3a7a855956004e38de7c6e2a/addons/mrp/models/stock_move.py#L164-L170


the UoM of `unit_factor` is `UoM_sm / UoM_mo`. Therefore, in
`_update_quantity_done` (see diff), when we compute `new_qty`, we have
(in terms of UoM) `(UoM_mo - UoM_mo) * UoM_sm / UoM_mo`. So, the value
is already in the correct UoM (`UoM_sm`) and we just have to round it
based on that UoM

OPW-3016837

closes odoo/odoo#104751

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent f07ee076
Branches
Tags
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment