I want to output a odoo 8 datetime field in the localization format but without time.
I extended the t-field
with the option hide_time
.
Is there a simpler built-in solution?
You can use formatLang
, <t-esc="formatLang(o.your_datatime_field,date=True)"/>
but you would need to override the report, as in this sample code:
#################
import time
from openerp.report import report_sxw
from openerp.osv import osv
class QuotationPrint(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
super(QuotationPrint, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
})
self.context = context
class quotation(osv.AbstractModel):
_name = 'report.sale.quotation_template'
_inherit = 'report.abstract_report'
_template = 'sale.quotation_template'
_wrapped_report_class = QuotationPrint
I have just faced this issue and now it's possible to do it in an easy way. This way shows only the date without the time in addition to keep the respective format lang of the date according to the user who printed the report.
<p t-field="o.your_datetime_field" t-field-options='{"widget": "date"}'/>
Warning: the quotes of t-field-options
must be exactly like I wrote, otherwise, that line won't work.
Hope it helps in the future to anyone who needs this.
You could try specifying a format in
t-field-options
, like this:just adjust the format as you want.