This commit is contained in:
2026-02-24 19:24:31 +01:00
parent c244cf658c
commit a1a13a6846

View File

@@ -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):