Skip to content

Commit 30c2463

Browse files
committed
Merge PR #737 into 13.0
Signed-off-by pedrobaeza
2 parents 1408b3e + e55397f commit 30c2463

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

delivery_cttexpress/models/delivery_carrier.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Copyright 2022 Tecnativa - David Vidal
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
import time
4+
35
from odoo import _, api, fields, models
46
from odoo.exceptions import UserError
57

@@ -38,6 +40,13 @@ class DeliveryCarrier(models.Model):
3840
string="Document format",
3941
)
4042
cttexpress_document_offset = fields.Integer(string="Document Offset")
43+
cttexpress_label_delay = fields.Float(
44+
string="Label Fetch Delay (seconds)",
45+
help="The server might not be ready to deliver the label right after the "
46+
"shipping is saved. We need to introduce a little delay. Tipacally 1 s will be "
47+
"enough",
48+
default=1,
49+
)
4150

4251
def _ctt_request(self):
4352
"""Get CTT Request object
@@ -253,6 +262,7 @@ def cttexpress_get_label(self, reference):
253262
if not reference:
254263
return False
255264
ctt_request = self._ctt_request()
265+
time.sleep(self.cttexpress_label_delay)
256266
try:
257267
error, label = ctt_request.get_documents_multi(
258268
reference,

delivery_cttexpress/views/delivery_cttexpress_view.xml

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
name="cttexpress_document_offset"
7373
attrs="{'required': [('delivery_type', '=', 'cttexpress')]}"
7474
/>
75+
<field name="cttexpress_label_delay" />
7576
</group>
7677
</group>
7778
</page>

0 commit comments

Comments
 (0)