Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
4450 Представления

I have set a report line as:

o.scheduled_date.strftime('%A, %d-%m-%Y, a las %H:%M')" style="color:red; font-size:24px;"/>

Everything is ok but the output day of the week is in English, I would like it in Spanish.

Tuesday 25/01/2022, a las 14:30 in place of Martes 25/01/2022 a las 14:30

Any idea in how to incorporate LOCALE to the field?

Thanks

Аватар
Отменить
Лучший ответ



In  Py


def locale_date(self,scheduled_date):
    if scheduled_date:
        loc = locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
        return scheduled_date.strftime('%A, %d-%m-%Y, a las %H:%M')


Hope it Helps,

Kiran K

Аватар
Отменить

In XML
<span t-esc="o.locale_date(o.scheduled_date)"/>

Автор

Thanks. It would change time_zone, but what i need is to change language to Spanish for de day of the week. So, Lunes in place of Monday.

It will change day also,
Output

Before - Wednesday, 26-01-2022, a las 09:58
After - Mittwoch, 26-01-2022, a las 09:58

Автор

Thanks a lot Kiran.
I use the XML option. How to define locale.setlocale y xml?

i need definition before p t-esc as follows

<p t-esc="o.locale_date(o.scheduled_date).strftime('%A, %d-%m-%Y, a las %H:%M')" style="color:red; font-size:24px;"/>

Write a method in py to set locale, Function called from XML with the date as a parameter and returned it after converting

In XML

<p t-esc="o.locale_date(o.scheduled_date)" style="color:red; font-size:24px;"/>

In Py

def locale_date(self,scheduled_date):
if scheduled_date:
loc = locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
return scheduled_date.strftime('%A, %d-%m-%Y, a las %H:%M')

Автор

Thanks a lot Kiran. I am trying to do it just in developer mode. So, no py involved

Лучший ответ

Thanks for the answer.s

Аватар
Отменить
Лучший ответ

I want to know how to set LOCALE in time format for PDF

Аватар
Отменить

Hi Francisca Ezell,

Try,

In XML

<p t-esc="o.locale_date(o.scheduled_date)" style="color:red; font-size:24px;"/>

In Py

def locale_date(self,scheduled_date):
if scheduled_date:
loc = locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
return scheduled_date.strftime('%A, %d-%m-%Y, a las %H:%M')

Related Posts Ответы Просмотры Активность
1
июн. 25
1601
3
июл. 25
3249
1
мая 25
1389
1
мая 25
1639
4
мая 25
2806