[FIX] website_sale: set partner lang according to website lang

On ecommerce checkout, the language of the partner wasn't set according to the language in which he is visiting the website.
Therefore, its partner was set with the default language (English in most cases), and any emails sent to him were not translated in his own language (in the email templates, such as the quotation email he received on order confirmation)
This commit is contained in:
Denis Ledoux 2014-12-08 17:48:00 +01:00
parent f2c5946051
commit cf4c826aa7
1 changed files with 10 additions and 2 deletions

View File

@ -510,7 +510,12 @@ class website_sale(http.Controller):
orm_user = registry.get('res.users')
order_obj = request.registry.get('sale.order')
billing_info = self.checkout_parse('billing', checkout, True)
partner_lang = request.lang if request.lang in [lang.code for lang in request.website.language_ids] else None
billing_info = {}
if partner_lang:
billing_info['lang'] = partner_lang
billing_info.update(self.checkout_parse('billing', checkout, True))
# set partner_id
partner_id = None
@ -531,7 +536,10 @@ class website_sale(http.Controller):
# create a new shipping partner
if checkout.get('shipping_id') == -1:
shipping_info = self.checkout_parse('shipping', checkout, True)
shipping_info = {}
if partner_lang:
shipping_info['lang'] = partner_lang
shipping_info.update(self.checkout_parse('shipping', checkout, True))
shipping_info['type'] = 'delivery'
shipping_info['parent_id'] = partner_id
checkout['shipping_id'] = orm_partner.create(cr, SUPERUSER_ID, shipping_info, context)