How can I output odut 8 datetime field without time in qweb report?

I want to output odoo 8 datetime field in localization format, but without time.

I expanded t-field with the hide_time option. Is there a simpler built-in solution?

+6
source share
5 answers

You can try to specify the format in t-field-options , for example:

 <span t-field="object.datetimefield" t-field-options='{"format": "MMMM dy"}'/> 

just adjust the format as you want.

+5
source

I just ran into this problem and now it can be done easily. This method only shows a date without time, in addition to saving the appropriate date lang format according to the user who printed the report.

 <p t-field="o.your_datetime_field" t-field-options='{"widget": "date"}'/> 

Warning: t-field-options quotes must be exactly the same as I wrote, otherwise this line will not work.

I hope that this will help in the future to everyone who needs it.

+3
source

You can use formatLang , <t-esc="formatLang(o.your_datatime_field,date=True)"/>

but you will need to override the report, as in this code example:

 ################# 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 

Source: https://www.odoo.com/es_ES/forum/help-1/question/how-output-a-odoo-8-datetime-field-without-time-on-a-qweb-report-67948

0
source

You can use QWeb parameters (t-field parameters). For instance:

 <div class="col-xs-6 text-center report-field"> <span t-field="ph_id.image_date" t-field-options='{"format":"d MMMM y"}'/> </div> 
0
source

You can use the following:

 <span t-esc="time.strftime('%m/%d/%Y',time.strptime(object.datetimefield,'%Y-%m-%d %H:%M:%S'))"/> 

Original Date Field:

15/01/2017 10:41:01

Field "Date of withdrawal":

01/15/2017

0
source

Source: https://habr.com/ru/post/978182/


All Articles