02.02.26
This commit is contained in:
@@ -9,6 +9,7 @@ import requests
|
|||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -84,6 +85,18 @@ class AutomationDocument(ModelSQL, ModelView, Workflow):
|
|||||||
doc.notes = (doc.notes or "") + "OCR done\n"
|
doc.notes = (doc.notes or "") + "OCR done\n"
|
||||||
else:
|
else:
|
||||||
doc.ocr_text = (doc.document.data or b"").decode('utf-8', errors='replace')
|
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:
|
except Exception as e:
|
||||||
doc.state = "error"
|
doc.state = "error"
|
||||||
|
|||||||
Reference in New Issue
Block a user