[FIX] stock: improve putaway when put in pack
Put in Pack won't trigger any onchange to use putaway rules. In this commit, we apply putaway rule in Put in Pack when only one move line is put in pack. We also check if the ml to put in pack are all in same package type, if so, we set that package type on the package. Task-2614519 X-original-commit: 023b69ac2ccac2456bcb1a8b1b66b468e213b86a Part-of: odoo/odoo#80519
This commit is contained in:
@@ -1360,18 +1360,28 @@ class Picking(models.Model):
|
||||
ml.write(vals)
|
||||
new_move_line.write({'product_uom_qty': done_to_keep})
|
||||
move_lines_to_pack |= new_move_line
|
||||
if not package.package_type_id:
|
||||
package_type = move_lines_to_pack.move_id.product_packaging_id.package_type_id
|
||||
if len(package_type) == 1:
|
||||
package.package_type_id = package_type
|
||||
if len(move_lines_to_pack) == 1:
|
||||
default_dest_location = move_lines_to_pack._get_default_dest_location()
|
||||
move_lines_to_pack.location_dest_id = default_dest_location._get_putaway_strategy(
|
||||
product=move_lines_to_pack.product_id,
|
||||
quantity=move_lines_to_pack.product_uom_qty,
|
||||
package=package)
|
||||
move_lines_to_pack.write({
|
||||
'result_package_id': package.id,
|
||||
})
|
||||
if create_package_level:
|
||||
package_level = self.env['stock.package_level'].create({
|
||||
'package_id': package.id,
|
||||
'picking_id': pick.id,
|
||||
'location_id': False,
|
||||
'location_dest_id': move_line_ids.mapped('location_dest_id').id,
|
||||
'location_dest_id': move_lines_to_pack.mapped('location_dest_id').id,
|
||||
'move_line_ids': [(6, 0, move_lines_to_pack.ids)],
|
||||
'company_id': pick.company_id.id,
|
||||
})
|
||||
move_lines_to_pack.write({
|
||||
'result_package_id': package.id,
|
||||
})
|
||||
return package
|
||||
|
||||
def action_put_in_pack(self):
|
||||
|
||||
Reference in New Issue
Block a user