Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4682 Widoki

i want to display only the year from request_date_from in a q-web report 

i tried this code 

 <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>

but i get this error 


Error to render compiling AST TypeError: strptime() argument 1 must be str, not datetime.date Template: mymodule.leave 
Path: /t/t/t/t/div/p/span
Node: <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>)
Awatar
Odrzuć
Autor

thank you  @Ravi Gadhia 

Najlepsza odpowiedź

<span t-field="o.request_date_from" t-options='{"format": "yyyy"}'/>

you can use any babel format http://babel.pocoo.org/en/latest/dates.html#date-fields

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lip 21
2107
2
mar 24
2423
1
lut 23
2907
1
paź 21
7732
3
cze 25
831