[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
This commit is contained in:
Denis Ledoux
2016-12-19 15:54:12 +01:00
parent f616b2d20d
commit cfb850cd77
+3 -2
View File
@@ -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: