From f7d6ed00fd392063619d68e156ff9d680fce361a Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Mon, 2 Feb 2026 17:02:14 +0100 Subject: [PATCH] 02.02.26 --- modules/automation/automation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/automation/automation.py b/modules/automation/automation.py index b562550..a7da6bc 100644 --- a/modules/automation/automation.py +++ b/modules/automation/automation.py @@ -9,6 +9,7 @@ import requests import io import logging import json +import re logger = logging.getLogger(__name__) @@ -84,6 +85,18 @@ class AutomationDocument(ModelSQL, ModelView, Workflow): doc.notes = (doc.notes or "") + "OCR done\n" else: doc.ocr_text = (doc.document.data or b"").decode('utf-8', errors='replace') + match = re.search(r"\bID\s*:\s*(\d+)", doc.ocr_text) + if match: + request_id = match.group(1) + match = re.search(r"\bBL\s*number\s*:\s*([A-Za-z0-9_-]+)", doc.ocr_text, re.IGNORECASE) + if match: + bl_number = match.group(1) + ShipmentIn = Pool().get('stock.shipment.in') + sh = ShipmentIn.search(['bl_number','=',bl_number]) + if sh: + sh[0].returned_id = request_id + ShipmentIn.save(sh) + doc.notes = (doc.notes or "") + "Id returned: " + request_id except Exception as e: doc.state = "error"