[FIX] stock: ensure safe UoM change for done smls
We fix 2 related UoM issues: 1. Fix quant inconsistency from changing the UoM of Done stock.move.lines Steps to reproduce: - Enable "Storage Locations" setting - Create a new "Storable Product" and create a receipt for 1 unit of it - Validate the 1 unit receieved - Open "Detailed Operations" of the move and change the stock.move.line UoM to dozen. Expected result: 13 on hand Actual result: 1 on hand To fix this: - prevent users from editing the UoM after the picking is done (i.e. unless adding a new stock.move.line and not saving). - update the write on done logic so stock.move.line UoM changes are considering and will update the quant correctly (in case of RPC or direct write). 2. Prevent changing UoM of Done stock.move to prevent inconsistent field values within stock.move and confusion for users Steps to reproduce: - Complete a picking (incoming is easiest to see) with a new product (i.e. 0 qty) having 1 unit done. - Unlock picking and add a new stock.move with 1 unit done and save. - Edit the just added stock.move's UoM from Units to Dozen. - Check the quantity on hand / Done qty of stock.move after leaving and returning to form. Expected result: 13 On Hand Actual Result: 2 On Hand and the "Done" qty in the picking is 0.0083 (i.e. 1/12 of a dozen) To fix this: - prevent users from editing the UoM after the picking is done (unless adding a new stock.move and not saving) - if a Done stock.move UoM is uodated, a UserError occurs because there is no straightforward way to ensure the quant is updated correctly since is handled within the move.line (i.e. has no visibility to its move's uom change => changing only UoM and not qty done will result in no quant update) closes odoo/odoo#75891 X-original-commit: 8ca10a8f Signed-off-by:Arnold Moyaux <amoyaux@users.noreply.github.com>
Showing
- addons/stock/models/stock_move.py 2 additions, 0 deletionsaddons/stock/models/stock_move.py
- addons/stock/models/stock_move_line.py 5 additions, 3 deletionsaddons/stock/models/stock_move_line.py
- addons/stock/tests/test_move.py 33 additions, 0 deletionsaddons/stock/tests/test_move.py
- addons/stock/views/stock_move_views.xml 6 additions, 3 deletionsaddons/stock/views/stock_move_views.xml
- addons/stock/views/stock_picking_views.xml 2 additions, 2 deletionsaddons/stock/views/stock_picking_views.xml
Loading
Please register or sign in to comment