From abdde7cbf5cfac8275c8edb5e3f823acc6a3b7d7 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 2 Jul 2020 08:24:49 +0200 Subject: [PATCH] Add stock_vertical_lift_storage_type Compatibility module between stock_vertical_lift and stock_storage_type (in OCA/wms). In the vertical lift's Putaway screen, when a good is scanned for a putaway, the user has to scan the tray type of the corresponding size, so an empty place in a matching tray is found. When we use storage types, we should know what tray is compatible with the storage type. Changes with this module: * The storage types of trays cannot be selected in the locations form, they have to be set in the Tray types. * In the lift put-away screen, when a package has a storage type, the user isn't asked to scan a tray type, instead, the putaway of the Package Storage Type is applied. --- .../models/vertical_lift_operation_put.py | 3 --- stock_vertical_lift/tests/common.py | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/stock_vertical_lift/models/vertical_lift_operation_put.py b/stock_vertical_lift/models/vertical_lift_operation_put.py index 4511359c3..886575b86 100644 --- a/stock_vertical_lift/models/vertical_lift_operation_put.py +++ b/stock_vertical_lift/models/vertical_lift_operation_put.py @@ -65,9 +65,6 @@ class VerticalLiftOperationPut(models.Model): _("No move line found for barcode {}").format(barcode) ) - # TODO if the move line already has a storage type, assign directly a - # destination and save - elif self.step() == "scan_tray_type": tray_type = self._find_tray_type(barcode) if tray_type: diff --git a/stock_vertical_lift/tests/common.py b/stock_vertical_lift/tests/common.py index 89ec8999e..717134df7 100644 --- a/stock_vertical_lift/tests/common.py +++ b/stock_vertical_lift/tests/common.py @@ -48,8 +48,18 @@ class VerticalLiftCase(common.LocationTrayTypeCase): "stock_vertical_lift." "stock_location_vertical_lift_demo_tray_2a_x1y1" ) - def _update_qty_in_location(self, location, product, quantity): - self.env["stock.quant"]._update_available_quantity(product, location, quantity) + @classmethod + def _update_qty_in_location( + cls, location, product, quantity, package=None, lot=None + ): + quants = cls.env["stock.quant"]._gather( + product, location, lot_id=lot, package_id=package, strict=True + ) + # this method adds the quantity to the current quantity, so remove it + quantity -= sum(quants.mapped("quantity")) + cls.env["stock.quant"]._update_available_quantity( + product, location, quantity, package_id=package, lot_id=lot + ) def _open_screen(self, mode, shuttle=None): getattr(shuttle or self.shuttle, "switch_{}".format(mode))()