[FIX] stock: multi-steps, backorders and return

1. Activate receipt in 3 steps
2. Make a PO of 50
3. Receive 20 (pick 1), backorder
4. Receive 29 (pick 2), backorder
5. Receive 1 (pick 3)
6. Transfer to quality check location 45 (pick 4), backorder (pick 5)
7. Go to pick 5, unreserve the quantity
8. Go to pick 3, return 1 => the quantity suggested by the return wizard is 1

The return is not able to reserve the necessary quantity.

This happens because 45 units are considerd out (from pick 4), but only
1 unit is considered in (pick 3). Therefore, in the following:

https://github.com/odoo/odoo/blob/23511dffb9e3f597a7df9bb834d008f74abb07b8/addons/stock/models/stock_move.py#L1276

we have `quantity = -44.0` and `available_quantity = 5.0`, so we can't
reserve.

We count as `move_orig_ids` all the siblings coming from
`move_dest_ids`.

opw-2261473

closes odoo/odoo#52084

X-original-commit: ba89e26750baab2309cccc4ffd0b3ade804d19ce
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Simon Lejeune
2020-05-28 11:53:14 +00:00
committed by Nicolas Martinelli
parent 0ef9289238
commit 0a768b9c3f
+7 -1
View File
@@ -142,8 +142,14 @@ class ReturnPicking(models.TransientModel):
# | return pick(Add as dest) return toLink return ship(Add as orig)
# +--------------------------------------------------------------------------------------------------------+
move_orig_to_link = return_line.move_id.move_dest_ids.mapped('returned_move_ids')
# link to original move
move_orig_to_link |= return_line.move_id
# link to siblings of original move, if any
move_orig_to_link |= return_line.move_id\
.move_dest_ids.filtered(lambda m: m.state not in ('cancel'))\
.move_orig_ids.filtered(lambda m: m.state not in ('cancel'))
move_dest_to_link = return_line.move_id.move_orig_ids.mapped('returned_move_ids')
vals['move_orig_ids'] = [(4, m.id) for m in move_orig_to_link | return_line.move_id]
vals['move_orig_ids'] = [(4, m.id) for m in move_orig_to_link]
vals['move_dest_ids'] = [(4, m.id) for m in move_dest_to_link]
r.write(vals)
if not returned_lines: