From a1a13a68466aeb3185281445ddc9b77fd9eac56c Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 24 Feb 2026 19:24:31 +0100 Subject: [PATCH] 24.02.26 --- modules/purchase_trade/stock.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index 95a17a4..61f96a1 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -728,6 +728,15 @@ class ShipmentIn(metaclass=PoolMeta): text = re.sub(r"<[^>]+>", "", text) return html.unescape(text).strip() + def create_service_order(self,so_payload): + response = requests.post( + "http://automation-service:8006/service-order", + json=so_payload, + timeout=10 + ) + response.raise_for_status() + return response.json() + @classmethod @ModelView.button def send(cls, shipments): @@ -779,6 +788,27 @@ class ShipmentIn(metaclass=PoolMeta): sh.result = f"Email sent on {now.strftime('%d/%m/%Y %H:%M')}" sh.save() + if sh.fees: + fee = sh.fees[0] + so_payload = { + "ControllerAlfCode": sh.controller.get_alf(), + "CurrKey": '3', + "Point1PlaceKey": sh.from_location.get_places(), + "Point2PlaceKey": sh.to_location.get_places(), + "OrderReference": sh.reference, + "FeeTotalCost": fee.amount, + "FeeUnitPrice": fee.price, + "ContractNumbers": sh.number, + "OrderQuantityGW": fee.quantity, + "NumberOfPackingBales": 1 + } + + logger.info("PAYLOAD:%s",so_payload) + data = sh.create_service_order(so_payload) + logger.info("SO_NUMBER:%s",data.get('service_order_number')) + sh.result += f" / SO Nb {data.get('service_order_number')}" + sh.save() + @classmethod @ModelView.button def compute(cls, shipments):