t-field-option is not working.
I have tried
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
t-field-option is not working.
I have tried
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
Instead of using
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
use
<span t-field="o.date_invoice" t-options='{"format": "MM/dd/yyyy"}'/>
Hope that helps!
For those who arrive here from search engines, you can control display of date in form fields using widgets.
<field name="date_planned" widget="date"/>
or,
<field name="date_planned" widget="datetime"/>
In v12, the date/datetime fields are python date/datetime objects and not string representations. The following python formatting will work in v12 reports:
<span t-esc="o.date_invoice.strftime('%m/%d/%Y')"/>
t-options='{"format": "yyyy/MM/dd"}'
but that didn't work. Using widget="date"
solved the problem. Thanks! –
Stereotomy MMM
or MMMM
. –
Marylandmarylee To display localized date strings. Try the following:
<span t-field="o.date_invoice" t-options="{"widget": "date"}" />
To delete the time section:
<span t-field="o.date_invoice" t-field-options='{"widget": "date"}'/>
Use t-field-options
instead of t-options
Do not change the position of the quotes in t-field-options
This code respects the format date according to lang/country.
Try this.
<span t-esc="datetime.datetime.strptime(o.sale_id.confirmation_date, '%Y-%m-%d %H:%M:%S').strftime('%B %d,%Y')"/>
My Output is: May 28,2018
According to my experience, you have used the correct way to format Qweb date, but sometimes there is problem in other thing and odoo gives error somewhere else. Hope trying this code may be helpful.
<span t-field="o.date_order" t-field-options='{"format": "d MMMM y"}'/>
also use this code
<span t-field="o.date_order" t-field-options="{'format': 'yyyy-MM-dd'}" />
You can also do one thing as formatting the date variable in the model itself and then show it on your QWeb report.
t-options
instead of t-field-options
–
Seddon © 2022 - 2024 — McMap. All rights reserved.