diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index f10330ab7be..43d0a354200 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -990,7 +990,7 @@ class Picking(models.Model): ) def _check_move_lines_map_quant_package(self, package): - return package._check_move_lines_map_quant(self.move_line_ids.filtered(lambda ml: ml.package_id == package)) + return package._check_move_lines_map_quant(self.move_line_ids.filtered(lambda ml: ml.package_id == package and ml.product_id.type == 'product')) def _get_entire_pack_location_dest(self, move_line_ids): location_dest_ids = move_line_ids.mapped('location_dest_id') diff --git a/addons/stock/tests/test_packing.py b/addons/stock/tests/test_packing.py index d26cdf742d8..b4c4d3071cf 100644 --- a/addons/stock/tests/test_packing.py +++ b/addons/stock/tests/test_packing.py @@ -418,6 +418,39 @@ class TestPacking(TestPackingCommon): with self.assertRaises(UserError): picking._action_done() + def test_pack_delivery_three_step_propagate_package_consumable(self): + """ Checks all works right in the following case: + * For a three-step delivery + * Put products in a package then validate the receipt. + * The automatically generated internal transfer should have package set by default. + """ + prod = self.env['product.product'].create({'name': 'bad dragon', 'type': 'consu'}) + ship_move = self.env['stock.move'].create({ + 'name': 'The ship move', + 'product_id': prod.id, + 'product_uom_qty': 5.0, + 'product_uom': prod.uom_id.id, + 'location_id': self.warehouse.wh_output_stock_loc_id.id, + 'location_dest_id': self.env.ref('stock.stock_location_customers').id, + 'warehouse_id': self.warehouse.id, + 'picking_type_id': self.warehouse.out_type_id.id, + 'procure_method': 'make_to_order', + 'state': 'draft', + }) + + # create chained pick/pack moves to test with + ship_move._assign_picking() + ship_move._action_confirm() + pack_move = ship_move.move_orig_ids[0] + pick_move = pack_move.move_orig_ids[0] + + picking = pick_move.picking_id + picking.action_confirm() + picking.action_put_in_pack() + self.assertTrue(picking.move_line_ids.result_package_id) + picking.button_validate() + self.assertEqual(pack_move.move_line_ids.result_package_id, picking.move_line_ids.result_package_id) + def test_pack_in_receipt_two_step_single_putway(self): """ Checks all works right in the following specific corner case: