From 152cb2a9f25cd4f9bd10ec62bb51e2693e1f8db7 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Tue, 1 Jun 2021 08:31:28 +0000 Subject: [PATCH] [FIX] stock: missing package when create stock move line When find putaway location while creating new sml, we didn't consider the package. Add it back. Task-2614519 X-original-commit: fcbd4c775248f18c71f9cb0e700ed9934babcdfd Part-of: odoo/odoo#80519 --- addons/stock/models/stock_move.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index d70f2b7757c..4e6f51f9a0c 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1278,14 +1278,11 @@ class StockMove(models.Model): def _prepare_move_line_vals(self, quantity=None, reserved_quant=None): self.ensure_one() - # apply putaway - location_dest_id = self.location_dest_id._get_putaway_strategy(self.product_id, quantity=quantity or 0, packaging=self.product_packaging_id).id vals = { 'move_id': self.id, 'product_id': self.product_id.id, 'product_uom_id': self.product_uom.id, 'location_id': self.location_id.id, - 'location_dest_id': location_dest_id, 'picking_id': self.picking_id.id, 'company_id': self.company_id.id, } @@ -1298,14 +1295,19 @@ class StockMove(models.Model): vals = dict(vals, product_uom_qty=uom_quantity) else: vals = dict(vals, product_uom_qty=quantity, product_uom_id=self.product_id.uom_id.id) + package = None if reserved_quant: + package = reserved_quant.package_id vals = dict( vals, location_id=reserved_quant.location_id.id, lot_id=reserved_quant.lot_id.id or False, - package_id=reserved_quant.package_id.id or False, + package_id=package.id or False, owner_id =reserved_quant.owner_id.id or False, ) + # apply putaway + location_dest_id = self.location_dest_id._get_putaway_strategy(self.product_id, quantity=quantity or 0, package=package, packaging=self.product_packaging_id).id + vals['location_dest_id'] = location_dest_id return vals def _update_reserved_quantity(self, need, available_quantity, location_id, lot_id=None, package_id=None, owner_id=None, strict=True):