Odoo Help


This community 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.


How to correct the decimal precision in email template?

Andreas Marpmann
on 8/12/14, 3:22 AM 1,470 views

In email templates the field ${object.amount_total} does not show the set decimal precision.

True / False
1.024,00 € = 1024.0 €


Ben Bernard

--Ben Bernard--
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 8/15/14, 5:05 AM

formatLang(object.amount_total, currency_obj=currency_object)

I believe you can get currency_object (EURO) from some field in the object, usually from company_id.

-- begin edited answer --

I'm forget to fact that object email template can't access report service. So, pass it to the template. In the model related to the email template define a method, something like this.

def parser(self, cr, uid, ids, context=None):

        report_service = 'dummy_report'

        service = netsvc.LocalService(report_service)
        parser = service.parser(cr, uid, service.name2, context)
        pool = self.pool.get('your.model')
        obj = pool.browse(cr, uid, ids, context) # relative to your model
        parser.set_context(obj, {'model': u'your.model'}, 'pdf') # whatever report type will suffice

        return parser

Then call it in your email template. Now the parser can access formatLang. Furhermore you can access all data to build that report.

I think this method is a little bit aggresive, I hope you can get the idea. I'm willing to see any improvement or new method :D





It would be great to have formatLang in email templates. But how is it possible? Your example will be displayed as plain text.

René Schuster
on 8/15/14, 5:34 AM

Hi, I already edited my answer.

Ben Bernard
on 8/15/14, 6:08 AM
On 11/16/14, 1:42 PM

I am looking for a solution for that, too. Did anybody succeed in solving the problem by Ben Bernard's advice?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


Asked: 8/12/14, 3:22 AM
Seen: 1470 times
Last updated: 12/7/15, 5:38 AM