Skip to Content
Menu
This question has been flagged
3 Replies
3228 Views

Using Odoo 10 Community Mass Mail. I wish to insert the partners object id into the email and pad it with Zeros up to 8.

I understand I can use mako commands such as ${object.id} to display this field and this does indeed work.

Being largely unfamiliar with python and mako, I've been unable to work out what to do and what syntax to use to produce and eight digit number in the email after hours of internet research, trial and error.

Example ID = 5535, I wish to display 00005536

Can any one provide the solution with context so I can implement what I hope is a very easy thing to do. I'd very much appreciate your help.

Thanks





Avatar
Discard
Best Answer

Hi Eric:

Use this:

${str(object.id).zfill(8)}


Avatar
Discard
Best Answer

you can eval expression in a template like

 ${(str(object.id) or '').zfill(8)}

Avatar
Discard
Author Best Answer

Thanks Ravi & Paresh,

I was on the right track. I had the right function, just couldn't figure the syntax. This has greatly helped my understanding. Much appreciated. I've done a test and it works.

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 24
462
1
Mar 24
585
1
Nov 22
4864
1
Apr 21
1098
2
Jun 20
2018