Skip to content

Commit

Permalink
Merge PR #737 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed May 14, 2024
2 parents 1408b3e + e55397f commit 870961d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions delivery_cttexpress/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2022 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import time

from odoo import _, api, fields, models
from odoo.exceptions import UserError

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

def _ctt_request(self):
"""Get CTT Request object
Expand Down Expand Up @@ -253,6 +262,7 @@ def cttexpress_get_label(self, reference):
if not reference:
return False
ctt_request = self._ctt_request()
time.sleep(self.cttexpress_label_delay)
try:
error, label = ctt_request.get_documents_multi(
reference,
Expand Down
1 change: 1 addition & 0 deletions delivery_cttexpress/views/delivery_cttexpress_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
name="cttexpress_document_offset"
attrs="{'required': [('delivery_type', '=', 'cttexpress')]}"
/>
<field name="cttexpress_label_delay" />
</group>
</group>
</page>
Expand Down

0 comments on commit 870961d

Please sign in to comment.