Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
28458 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
dic 23
45217
1
nov 23
1279
2
mar 16
3552
1
mar 15
7848
2
mag 22
16303