Skip to content

Commit

Permalink
Merge pull request #170 from akretion/delivery-instruction-roulier-an…
Browse files Browse the repository at this point in the history
…d-dpd

[IMP] Port delivery_instruction from python 2 old branch for dpd
  • Loading branch information
florian-dacosta authored Mar 15, 2024
2 parents 536ba77 + 925f712 commit 6ad56e4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions roulier/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ def _to_address(self):
address["country"].update({"required": True, "empty": False})
address["city"].update({"required": True, "empty": False})
address["zip"].update({"required": True, "empty": False})
address["delivery_instruction"] = {
"type": "string",
"default": "",
"required": False,
"empty": True,
}
return address

def _parcel(self):
Expand Down
2 changes: 2 additions & 0 deletions roulier/carriers/dpd_fr_soap/templates/dpd_addressInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
<car:digicode1>{{ address.digicode1 }}</car:digicode1>
<car:digicode2>{{ address.digicode2 }}</car:digicode2>
<car:intercomid>{{ address.intercom }}</car:intercomid>
<car:vinfo1>{{ address.delivery_instruction[0:35] }}</car:vinfo1>
<car:vinfo2>{{ address.delivery_instruction[35:70] }}</car:vinfo2>
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<car:CreateShipmentWithLabels{{ '' if legacy else 'Bc'}} xmlns:car="http://www.cargonet.software">
<car:request>
{% with address = receiver_address %}
<car:customLabelText>
{{ address.delivery_instruction }}
</car:customLabelText>
<car:receiveraddress>
{% include "dpd_address.xml" %}
</car:receiveraddress>
Expand Down
1 change: 0 additions & 1 deletion roulier/carriers/dpd_fr_soap/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def _get_requests_headers(self, payload=None):

def handle_500(self, response):
"""Handle reponse in case of ERROR 500 type."""
log.warning("Dpd error 500")
obj = objectify.fromstring(response.content)
error_id = (obj.xpath("//ErrorId") or obj.xpath("//faultcode"))[0]
error_message = (obj.xpath("//ErrorMessage") or obj.xpath("//faultstring"))[0]
Expand Down
1 change: 0 additions & 1 deletion roulier/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def encode(self, input_payload):
"""Transform input from external app to compatible input for carrier webservice."""
validator = self.config.api(self.config)
if not validator.validate(input_payload):
_logger.warning("api call exception:")
raise InvalidApiInput(
{"api_call_exception": validator.errors(input_payload)}
)
Expand Down

0 comments on commit 6ad56e4

Please sign in to comment.