[FIX] stock_picking_batch: add picks to batch

When adding list of transfers to batch from transfer tree view,
if transfers belong to two or more batches an error traceback pops.

To reproduce:

1-Create Transfer 1, go to Transfer list view and add it to batch under Action, choose
add to a new batch transfer and confirm.
2-Create Transfer 2 and do the same.
3-Now that we have two transfer belonging to two different batches,
Under Inventory->Operations->Transfers, select the two transfers
in the tree view and choose add to batch under Action, choose add to new batch
and confirm, error popsup

Bug originated from: #89815
Discovered while working on TaskId:2871679

closes odoo/odoo#97998

X-original-commit: 82580b0ba9dbbfb244ede233a251b059e2c233ba
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Ahmed Khalaf  <ahkh@odoo.com>
This commit is contained in:
Ahmed Khalaf (ahkh)
2022-08-16 16:28:22 +02:00
parent af6afc8053
commit 8b8eca55c6
@@ -166,8 +166,8 @@ class StockPickingBatch(models.Model):
def write(self, vals):
res = super().write(vals)
if not self.picking_ids and self.state == 'in_progress':
self.action_cancel()
if not self.picking_ids:
self.filtered(lambda b: b.state == 'in_progress').action_cancel()
if vals.get('picking_type_id'):
self._sanity_check()
if vals.get('picking_ids'):