From 8474358027646296ee7a8da4e620b23b60fb3f09 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Wed, 2 Aug 2023 19:28:47 +0200 Subject: [PATCH] Sync secondary unit on supplier and internal shipments When synchronize the outgoing or incoming move, the secondary unit must be copied from the template. Closes #12301 (grafted from b190ea97bd1a2040686ed6c9565ac20c45c529f4) --HG-- branch : 6.0 --- modules/stock_secondary_unit/__init__.py | 1 + modules/stock_secondary_unit/stock.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/modules/stock_secondary_unit/__init__.py b/modules/stock_secondary_unit/__init__.py index cd40ef6a0a..9edfb707d0 100644 --- a/modules/stock_secondary_unit/__init__.py +++ b/modules/stock_secondary_unit/__init__.py @@ -13,4 +13,5 @@ def register(): stock.ShipmentIn, stock.ShipmentOut, stock.ShipmentOutReturn, + stock.ShipmentInternal, module='stock_secondary_unit', type_='model') diff --git a/modules/stock_secondary_unit/stock.py b/modules/stock_secondary_unit/stock.py index 1ae73c773b..4338dd49db 100644 --- a/modules/stock_secondary_unit/stock.py +++ b/modules/stock_secondary_unit/stock.py @@ -153,6 +153,12 @@ class ShipmentOut(metaclass=PoolMeta): inventory_move.secondary_unit = move.secondary_unit return inventory_move + def _sync_outgoing_move(self, template=None): + move = super()._sync_outgoing_move(template) + if template: + move.secondary_unit = template.secondary_unit + return move + class ShipmentOutReturn(metaclass=PoolMeta): __name__ = 'stock.shipment.out.return' @@ -162,3 +168,13 @@ class ShipmentOutReturn(metaclass=PoolMeta): if move: move.secondary_unit = incoming_move.secondary_unit return move + + +class ShipmentInternal(metaclass=PoolMeta): + __name__ = 'stock.shipment.internal' + + def _sync_incoming_move(self, template=None): + move = super()._sync_incoming_move(template) + if template: + move.secondary_unit = template.secondary_unit + return move