From cfb850cd77e561cb4a6ff166640fbd2307fcd15b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 19 Dec 2016 15:52:23 +0100 Subject: [PATCH] [FIX] hr_payroll: month name in the user language In the payslip name, the month name was set within the server locale, rather than the user language. Therefore, if you had your server default locale in English but your user in French, the month name was displayed in English anyway. opw-692590 --- addons/hr_payroll/hr_payroll.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 8549a93d833..5271d93efe6 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -1,6 +1,7 @@ #-*- coding:utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import babel import time from datetime import date from datetime import datetime @@ -637,7 +638,7 @@ class hr_payslip(osv.osv): ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d"))) employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context) res['value'].update({ - 'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))), + 'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=self.env.context.get('lang', 'en_US')))), 'company_id': employee_id.company_id.id }) @@ -696,7 +697,7 @@ class hr_payslip(osv.osv): date_to = self.date_to ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d"))) - self.name = _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))) + self.name = _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=self.env.context.get('lang', 'en_US')))) self.company_id = employee_id.company_id if not self.env.context.get('contract') or not self.contract_id: