On a picking, it is not always easy to make the difference between a
waiting SM and a cancelled one.
To reproduce the issue:
1. Create two storable products P1, P2 with on hand qty > 1
2. Create and confirm a SO with 1 x P1 and 1 x P2
3. On the delivery, set the done quantities
4. Edit the SO: 0 x P1
5. Validate the delivery
Error: The SM of P1 is a bit confusing. Its demand is 0, which makes
sense because of step 4. However, its done quantity is 1 although
nothing moved according to the quants. Actually, the SM is cancelled
but nothing gives this information UI side, hence the confusion.
Step 4, we decrease the qty. It creates and runs a procurement of -1,
which creates a SM with a demand of -1. We then merge it with the SM
of the delivery and since its demand becomes 0, we cancel it:
https://github.com/odoo/odoo/blob/aebe6e616c4d62010aba67e7c4fbcc82f1385bea/addons/stock/models/stock_move.py#L1003-L1007
However, nothing displays this information client side. When the
picking is not done, the line will be red because the done quantity is
greater than the reservation (see `decoration-danger`):
https://github.com/odoo/odoo/blob/aebe6e616c4d62010aba67e7c4fbcc82f1385bea/addons/stock/views/stock_picking_views.xml#L254
When the picking is `done`, both lines will be grey (see
`decoration-muted` in above code). Therefore, the information is not
clear for the user, he could beleive that the SM has been processed.
Moreover, the user has completed the line with a done quantity. We
can't decide for him that this quantity no longer has any value. If
he really has moved the product, we have to consider it on Odoo side.
Else, he has to update the done quantity himself.
OPW-3478871
closesodoo/odoo#139495
X-original-commit: d5a1c6bfadc28503a6928580e854264e94074fa0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>