Skip to content

Commit

Permalink
Merge PR OCA#1720 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Sep 18, 2024
2 parents 4aeadf6 + 4d7b129 commit 8529931
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stock_picking_auto_create_package/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def _auto_create_delivery_package_per_smallest_packaging(self) -> None:
continue
qty_to_pack = move_line.qty_done
max_pack_qty = 1
packagings = move_line.product_id.packaging_ids
packagings = move_line.product_id.packaging_ids.filtered(
lambda pack: pack.qty > 0
)
if packagings:
smallest_packaging = packagings.filtered(
lambda pack: pack.qty > 0
).sorted("qty")[0]
smallest_packaging = packagings.sorted("qty")[0]
max_pack_qty = smallest_packaging.qty
while qty_to_pack:
pack_qty = min(qty_to_pack, max_pack_qty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ def test_automatic_packaging_no_product_packaging(self):
self.picking._action_done()
self.assertTrue(self.picking.move_line_ids.result_package_id)
self.assertTrue(len(self.picking.move_line_ids.result_package_id), 5)

def test_automatic_packaging_with_qty_zero_on_packaging(self):
self.picking.picking_type_id.automatic_package_creation_mode = "packaging"
self.product_packaging.qty = 0
self.picking._action_done()
self.assertTrue(self.picking.move_line_ids.result_package_id)
self.assertTrue(len(self.picking.move_line_ids.result_package_id), 5)

0 comments on commit 8529931

Please sign in to comment.