コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
28203 ビュー

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)?


アバター
破棄
最善の回答

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')

アバター
破棄
関連投稿 返信 ビュー 活動
3
12月 23
44772
1
11月 23
1131
2
3月 16
3402
1
3月 15
7676
2
5月 22
16093