Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
28575 Visninger

I'm modifing a module to get the full month (translated) instead of Y/m/d:

old: new_date.strftime('%Y-%m-%d')

new: new_date.strftime('%B')

%B gives the full month in english, how can I translate the month in the current Odoo language setting using python code (not qweb)?


Avatar
Kassér
Bedste svar

import locale


# Change timelocale to current account's language setting in Odoo.

locale.setlocale(locale.LC_TIME, self.env.context['lang'] + '.utf8')


# example (hardcoded) for dutch:

# locale.setlocale(locale.LC_TIME, 'nl_NL.utf8')


# proof of concept

from datetime import datetime

new_date = datetime.now()

new_date.strftime('%B')

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
dec. 23
45346
1
nov. 23
1361
2
mar. 16
3634
1
mar. 15
7924
2
maj 22
16396