From f4f4a9cec1b73ddeb6af6a90c7ec32ae792c278e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 23 Aug 2023 19:45:33 +0200 Subject: [PATCH] Check outgoing product quantities for internal shipment --- modules/stock/CHANGELOG | 1 + modules/stock/shipment.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/stock/CHANGELOG b/modules/stock/CHANGELOG index c053a849d6..d34026fec4 100644 --- a/modules/stock/CHANGELOG +++ b/modules/stock/CHANGELOG @@ -1,3 +1,4 @@ +* Check outgoing product quantities for internal shipment * Check inventory product quantities for customer return shipment * Check outgoing product quantities of customer shipment * Check inventory product quantities of supplier shipment diff --git a/modules/stock/shipment.py b/modules/stock/shipment.py index 7d4ae1b677..02bcf258e9 100644 --- a/modules/stock/shipment.py +++ b/modules/stock/shipment.py @@ -2290,7 +2290,9 @@ class ShipmentOutReturn( cls.save(shipments) -class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): +class ShipmentInternal( + ShipmentCheckQuantity, ShipmentAssignMixin, Workflow, ModelSQL, + ModelView): "Internal Shipment" __name__ = 'stock.shipment.internal' _rec_name = 'number' @@ -2893,7 +2895,12 @@ class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): pool = Pool() Move = pool.get('stock.move') Date = pool.get('ir.date') - Move.do([m for s in shipments for m in s.incoming_moves]) + incoming_moves = [] + for shipment in shipments: + if shipment.transit_location: + shipment.check_quantity() + incoming_moves.extend(shipment.incoming_moves) + Move.do(incoming_moves) for company, c_shipments in groupby( shipments, key=lambda s: s.company): with Transaction().set_context(company=company.id): @@ -2902,6 +2909,14 @@ class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): 'effective_date': today, }) + @property + def _check_quantity_source_moves(self): + return self.incoming_moves + + @property + def _check_quantity_target_moves(self): + return self.outgoing_moves + @classmethod @ModelView.button @Workflow.transition('cancelled')