This question has been flagged
5 Replies
17746 Views

I want output a odoo 8 datetime field in the localization format but without time.
I extended the t-field with a option hide_time.
Is there a simpler build in solution?

Thanks
 

Avatar
Discard
Best Answer

This is lovely! :) I found my own answer, but it didn't work this time (version 12). It turned out that f-field-options turned into t-options in the meantime. So I modified it accordingly.


MORE UNIVERSAL:

<span t-field="o.scheduled_date" t-options="{'widget': 'date'}" />
Avatar
Discard
Best Answer

You can use below this code. 
<span t-field="o.your_date_field" t-field-options='{"format": "dd/MMM/yyyy"}'/>

Avatar
Discard

Thanks it works for me.

Best Answer

Use the below code:

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

Original Date field:

01/15/2016 10:41:01

Output Date field:

01/15/2016



Avatar
Discard
Best Answer

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

but u need to override the report ,as given 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

 

Avatar
Discard