Skip to content

Commit c6af2ad

Browse files
[IMP] set timeout on system parameter
[IMP] set timeout on system parameter
1 parent 2d129db commit c6af2ad

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

zort_connector/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"depends": ["base", "stock", "sale_management"],
1313
"data": [
1414
"data/ir_actions_server_data.xml",
15+
"data/ir_config_parameter_data.xml",
1516
"data/ir_cron_data.xml",
1617
"data/partner_data.xml",
1718
"data/product_data.xml",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="zort_connector_limit_timeout" model="ir.config_parameter">
4+
<field name="key">zort_connector.limit_timeout</field>
5+
<field name="value">10</field>
6+
</record>
7+
</odoo>

zort_connector/zort_api/zort_api.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,22 @@ def _api_request(
9494
headers.update(headers_extra)
9595

9696
try:
97+
timeout = int(
98+
self.env["ir.config_parameter"]
99+
.sudo()
100+
.get_param("zort_connector.limit_timeout", 10)
101+
)
97102
if method.upper() == "GET":
98-
response = requests.get(url, headers=headers, params=params, timeout=10)
103+
response = requests.get(
104+
url, headers=headers, params=params, timeout=timeout
105+
)
99106
elif method.upper() == "POST":
100107
response = requests.post(
101108
url,
102109
headers=headers,
103110
params=params,
104-
data=json.dumps(data) if data else None,
105-
timeout=10,
111+
json=data if data else None,
112+
timeout=timeout,
106113
)
107114
else:
108115
raise ValueError(f"Unsupported HTTP method: {method}")

0 commit comments

Comments
 (0)