summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-05 10:36:28 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-05 10:36:28 +0700
commitd9ddc88ea00a5c86c7cf82552970ab0c917d8544 (patch)
tree5ac0157a219d12792ade8856be7630d1d280dc48 /indoteknik_custom/models
parente5b1c4117bd887b1e77c0aa8117b79646397855b (diff)
(andri) add patch untuk webhook biteship
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/patch/__pycache__/__init__.py1
-rw-r--r--indoteknik_custom/models/patch/__pycache__/http_override.py46
3 files changed, 48 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 83392d42..cc406c13 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -152,3 +152,4 @@ from . import stock_inventory
from . import sale_order_delay
from . import approval_invoice_date
from . import approval_payment_term
+from . import patch
diff --git a/indoteknik_custom/models/patch/__pycache__/__init__.py b/indoteknik_custom/models/patch/__pycache__/__init__.py
new file mode 100644
index 00000000..051b6537
--- /dev/null
+++ b/indoteknik_custom/models/patch/__pycache__/__init__.py
@@ -0,0 +1 @@
+from . import http_override \ No newline at end of file
diff --git a/indoteknik_custom/models/patch/__pycache__/http_override.py b/indoteknik_custom/models/patch/__pycache__/http_override.py
new file mode 100644
index 00000000..e1978edb
--- /dev/null
+++ b/indoteknik_custom/models/patch/__pycache__/http_override.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+import odoo.http
+import json
+import logging
+from werkzeug.exceptions import BadRequest
+import functools
+
+_logger = logging.getLogger(__name__)
+
+class CustomJsonRequest(odoo.http.JsonRequest):
+ def __init__(self, httprequest):
+ super(odoo.http.JsonRequest, self).__init__(httprequest)
+
+ self.params = {}
+ request_data_raw = self.httprequest.get_data().decode(self.httprequest.charset)
+
+ self.jsonrequest = {}
+ if request_data_raw.strip():
+ try:
+ self.jsonrequest = json.loads(request_data_raw)
+ except ValueError:
+ msg = 'Invalid JSON data: %r' % (request_data_raw,)
+ _logger.info('%s: %s (Handled by CustomJsonRequest)', self.httprequest.path, msg)
+ raise BadRequest(msg)
+ else:
+ _logger.info("CustomJsonRequest: Received empty or whitespace-only JSON body. Treating as empty JSON for webhook.")
+
+ self.params = dict(self.jsonrequest.get("params", {}))
+ self.context = self.params.pop('context', dict(self.session.context))
+
+
+_original_get_request = odoo.http.Root.get_request
+
+@functools.wraps(_original_get_request)
+def _get_request_override(self, httprequest):
+ _logger.info("--- DEBUG: !!! _get_request_override IS CALLED !!! ---")
+ _logger.info(f"--- DEBUG: Request Mimetype: {httprequest.mimetype}, Path: {httprequest.path} ---")
+
+ if httprequest.mimetype in ("application/json", "application/json-rpc"):
+ _logger.debug("Odoo HTTP: Using CustomJsonRequest for mimetype: %s", httprequest.mimetype)
+ return CustomJsonRequest(httprequest)
+ else:
+ _logger.debug("Odoo HTTP: Using original get_request for mimetype: %s", httprequest.mimetype)
+ return _original_get_request(self, httprequest)
+
+odoo.http.Root.get_request = _get_request_override \ No newline at end of file