[FIX] delivery: traceback on single tracker

When using easypost, it could exist more than one tracking
link. In this case they are stored as a json and the method
open_url try to load it as a list of url. Then it checks if there is
more than one url or not. However in a single case, there is only one
string and the lenght of a string is the number of chracter inside that
is often more than one.
This commit is contained in:
Arnold Moyaux
2018-06-26 13:16:27 +02:00
parent 3ea85a603e
commit 86cb5203a1
2 changed files with 10 additions and 11 deletions
+9 -10
View File
@@ -184,21 +184,20 @@ class StockPicking(models.Model):
carrier_trackers = json.loads(self.carrier_tracking_url)
except ValueError:
carrier_trackers = self.carrier_tracking_url
if len(carrier_trackers) > 1:
else:
msg = "Tracking links for shipment: <br/>"
for tracker in carrier_trackers:
msg += '<a href=' + tracker[1] + '>' + tracker[0] + '</a><br/>'
self.message_post(body=msg)
return self.env.ref('delivery.act_delivery_trackers_url').read()[0]
else:
client_action = {
'type': 'ir.actions.act_url',
'name': "Shipment Tracking Page",
'target': 'new',
'url': self.carrier_tracking_url,
}
return client_action
client_action = {
'type': 'ir.actions.act_url',
'name': "Shipment Tracking Page",
'target': 'new',
'url': self.carrier_tracking_url,
}
return client_action
@api.one
def cancel_shipment(self):
+1 -1
View File
@@ -302,7 +302,7 @@
<form string="Trackers URL">
<group>
<div class="alert alert-info">
<p>You have multiple URL, they should be available in the chatter.</p>
<p>You have multiple tracker links, they are available in the chatter.</p>
</div>
</group>
<footer>