From 7431bc2ef0c73fd08bc1a1e5aec581d4b05c79f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Oct 2016 11:10:46 +0200 Subject: [PATCH] Normalize language to include country code Since changeset 66058a05f1, the language can be two code only so we need to normalize it as the DPD API always requires the country code. issue5976 review27761002 --- carrier.py | 3 +++ stock.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/carrier.py b/carrier.py index 445fff6428..b2192ce817 100644 --- a/carrier.py +++ b/carrier.py @@ -1,5 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +import locale + from zeep.exceptions import Fault from trytond.model import ModelSQL, ModelView, MatchMixin, fields @@ -40,6 +42,7 @@ class CredentialDPD(ModelSQL, ModelView, MatchMixin): auth_client = get_client(self.server, LOGIN_SERVICE) lang = (self.company.party.lang.code if self.company.party.lang else 'en') + lang = locale.normalize(lang)[:5] try: result = auth_client.service.getAuth( delisId=self.user_id, password=self.password, diff --git a/stock.py b/stock.py index b7ded5ced4..0913795f18 100644 --- a/stock.py +++ b/stock.py @@ -1,6 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +import locale from io import BytesIO from lxml import etree from zeep.exceptions import Fault @@ -102,6 +103,7 @@ class CreateDPDShipping(Wizard): while count < 2: lang = (credential.company.party.lang.code if credential.company.party.lang else 'en') + lang = locale.normalize(lang)[:5] authentication = { 'delisId': credential.user_id, 'authToken': credential.token,