Skip to content

Commit

Permalink
[FIX] stock_picking_batch: put in pack move lines from different picking
Browse files Browse the repository at this point in the history
Steps to reproduce the bug:
- Enable “package” option in the settings
- Create a storable product “P1”
- update the stock to 100
- Create a picking:
    - product : P1
    - Qty: 1
    - operation type: delivery
    - go to additional info > add a carrier
    - Mark as todo
    - update the qty done to 1
- Create a second picking with the same steps

- Create a batch picking:
    - Add the picking 1 and 2
    - Confirm
    - Go to “Detailed operation” tab
    - Click on “Put in pack”
    - add a “Delivery packaging”
    - Save
    - Click a second time on “Put in pack”
    - Select the same “Delivery packaging”
    - Save

Problem:
Traceback is triggered: “tuple index out of range”

When the “Put in pack” button is clicked, the “action_put_in_pack”
function is called, the move_line_ids which has no package or with
a 0 quantity done are filtered, in this case the 2nd move_line with
the product “P2” will be used, but the `_pre_put_in_pack_hook` function
is not called with its picking:

https://github.com/odoo/odoo/blob/14.0/addons/stock_picking_batch/models/stock_picking_batch.py#L229

But rather with the first picking, it will have no move_line because the
first move_line already has a quantity done at 1 and a package.
So we try to get a record in an empty array:
https://github.com/odoo/odoo/blob/14.0/addons/stock/models/stock_picking.py#L1312

opw-3067921

closes #106332

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
  • Loading branch information
DjamelTouati committed Nov 30, 2022
1 parent a44a035 commit 1b6208a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/stock_picking_batch/models/stock_picking_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def action_put_in_pack(self):
precision_rounding=ml.product_uom_id.rounding) > 0 and float_compare(ml.qty_done, 0.0,
precision_rounding=ml.product_uom_id.rounding) == 0)
if move_line_ids:
res = self.picking_ids[0]._pre_put_in_pack_hook(move_line_ids)
res = move_line_ids.picking_id[0]._pre_put_in_pack_hook(move_line_ids)
if not res:
res = self.picking_ids[0]._put_in_pack(move_line_ids, False)
res = move_line_ids.picking_id[0]._put_in_pack(move_line_ids, False)
return res
else:
raise UserError(_("Please add 'Done' quantities to the batch picking to create a new pack."))
Expand Down

0 comments on commit 1b6208a

Please sign in to comment.