[FIX] stock: Add missing packaging when find a putaway location

When apply a putaway rule to find a putaway location, we only pass the
product and/or package info to _get_putaway_location. This is not
enough since the putaway rule can also be applied to packaging.

X-original-commit: 9f339938aec075c5385dca349dfc6a7c2d43b6ad
Part-of: odoo/odoo#80519
This commit is contained in:
yhu-odoo
2021-11-30 14:31:07 +00:00
parent 6206b0858b
commit 87fd6b7692
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -96,8 +96,13 @@ class StockPutawayRule(models.Model):
raise UserError(_("Changing the company of this record is forbidden at this point, you should rather archive it and create a new one."))
return super(StockPutawayRule, self).write(vals)
def _get_putaway_location(self, product, quantity=0, package=None, qty_by_location=None):
package_type = package and package.package_type_id or None
def _get_putaway_location(self, product, quantity=0, package=None, packaging=None, qty_by_location=None):
# find package type on package or packaging
package_type = self.env['stock.package.type']
if package:
package_type = package.package_type_id
elif packaging:
package_type = packaging.package_type_id
checked_locations = set()
for putaway_rule in self:
+1 -1
View File
@@ -262,7 +262,7 @@ class Location(models.Model):
for values in quant_data:
qty_by_location[values['location_id'][0]] += values['quantity']
putaway_location = putaway_rules._get_putaway_location(product, quantity, package, qty_by_location)
putaway_location = putaway_rules._get_putaway_location(product, quantity, package, packaging, qty_by_location)
if not putaway_location:
putaway_location = locations[0] if locations and self.usage == 'view' else self