İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
28610 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Ara 23
45391
1
Kas 23
1381
2
Mar 16
3649
1
Mar 15
7938
2
May 22
16422