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
This commit is contained in:
Cédric Krier committed 2016-10-25 11:10:46 +02:00
1 parent a4f706ae4c
commit 7431bc2ef0
2 files changed
+5

No files matched your search

+3
View File
@@ -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,
+2
View File
@@ -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,