跳至内容
菜单
此问题已终结
7 回复
10542 查看

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

True / False
1.024,00 € = 1024.0 €

形象
丢弃
最佳答案

 Hello Guys,

you can edit your template with following.

${"%.2f" % object.amount_total} 

形象
丢弃
最佳答案

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.

Hi, I already edited my answer.

最佳答案

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

形象
丢弃
最佳答案

Hi!

In your mail.template, replace with t-esc="'%.2f' % (object.amount)"

形象
丢弃
最佳答案

Because I also encountered this issue, here's a easier work-around :

In your mail.template, replace ${object.amount_total} with ${"%.2f" | format(object.amount_total)}

Enjoy !

形象
丢弃
相关帖文 回复 查看 活动
0
12月 24
9119
3
9月 24
21137
5
12月 24
52272
4
7月 24
10173
36
4月 23
37518