Odoo Help


How to format a date while printing in rml or in openoffice report

on 6/12/13, 3:39 AM 7,231 views


Can anyone tell me how to print a date in a desired format in openerp reports. I use both rml and openoffice for reporting

Default Date format in form


Default Date format while printing in reports


My Desired Format


Thanks for your time


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 6/12/13, 3:49 AM

Write following code in report py:

import time
from datetime import datetime

'get_my_date': self.get_my_date, #Add this line in self.localcontext.update dictionary

def get_my_date(self, date):
    return time.strftime('%d') + '-' + datetime.strptime(date, '%d-%m-%Y').strftime('%b').upper() + '-' + time.strftime('%Y')

Call this method from your rml file:

<para style="P2"> [[ get_my_date(your_date) ]] </para>

Thanks sudir, How do i do this with regard to openoffice report i.e when i design a report in openoffice.

on 6/12/13, 5:00 AM

You can write [[ get_my_date(your_date) ]] code in sxw file also but you must have to write given method in report py file.

Sudhir Arya (ERP Harbor Consulting Services)
on 6/12/13, 5:07 AM

Yeah, but there's a problem in there sudir, There's a default sxw file in every module is not considered while printing. It's taken a copy when i take it and in the copy we've modified the above line and sent it to server. Nothing gets printed. Kindly guide me.

on 6/12/13, 5:29 AM

Either you can make changes in rml or first change in sxw, then convert it in rml and replace original rml with you new rml.

Sudhir Arya (ERP Harbor Consulting Services)
on 6/12/13, 6:49 AM

hi where to put 'get_my_date': self.get_my_date, code if i want to change format of date in meeting custom report in crm module

Hany Mansour
on 3/18/14, 9:08 AM

I already have written it in comment that you have to put it in "self.localcontext" in your report py file.

Sudhir Arya (ERP Harbor Consulting Services)
on 3/19/14, 2:11 AM
On 6/12/13, 6:50 AM

If you are adding the fields through the openoffice report editor, try this:

[[ formatLang(o.date_start,date_time=True) ]] (for date + hours) or [[ formatLang(o.date_start,date=True) ]] (date)

Just replace "date_time" with your field. Take heed: this will not show it like your desired format, but it will be better than the default output.

For a better solution, follow Sudhir's instructions.

Raminder Pal Singh
On 6/12/13, 7:53 AM

use [[ time.strftime('%d-%B-%Y') ]]

thank you for this answer, do you know how to add customer's contact person to report ?

Ahmed elbarbary
on 10/23/14, 2:48 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/12/13, 3:39 AM
Seen: 7231 times
Last updated: 3/16/16, 12:13 PM