[FIX] stock_picking_batch: put in pack move lines from different picking
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 odoo/odoo#106943
X-original-commit: 1b6208a2db00ed387bcd0833787fa05416a426ba
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
@@ -278,9 +278,9 @@ class StockPickingBatch(models.Model):
|
||||
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."))
|
||||
|
||||
Reference in New Issue
Block a user