Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
4449 Vues

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

Avatar
Ignorer
Meilleure réponse



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

Avatar
Ignorer

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

Auteur

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

Auteur

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

Auteur

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

Meilleure réponse

Thanks for the answer.s

Avatar
Ignorer
Meilleure réponse

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

Avatar
Ignorer

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

Publications associées Réponses Vues Activité
1
juin 25
1601
3
juil. 25
3249
1
mai 25
1389
1
mai 25
1639
4
mai 25
2806