Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
5565 Prikazi

Hey all.

I'm trying to get my email to dynamically insert a contact's first name only.

${object.name} works fine for the full name. But the emails are meant to look like a personal correspondence. So it needs to be the first name only. 

Can anyone help me out?

Avatar
Opusti
Best Answer

Hello Hagerman Jason,

Try this ${object.name} instead of this ${ object.name.split()[0]}.

Hope this solution is helpful for you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Opusti
Avtor

Works like a charm. Thanks Jainesh!

Avtor

Jainesh - I have a follow up you can probably help me with too.

How about in Odoo 15? I have a different client using that version and the dynamic insertion for company name and for contact name don't work at all.

I've read the documentation and I can't wrap my head around why it isn't working.

Thanks. I appreciate the help.

Hello Hagerman Jason,

You need to write this way “<t t-out="object.name.split()[0] or ''">” in version 15.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

You may want to take into consideration the record type inserted in res_partenr. For example if you are sending the Invoice to Accounts payable, the code above will send the message to Dear Account,

Something like this may work:

<t t-if="object.partner_id.type =='contact'" data-oe-t-group="0" data-oe-t-selectable="true" data-oe-t-inline="true">
<t t-out="object.partner_id.name.split() [0] or ''" data-oe-t-inline="true" data-oe-t-selectable="true" contenteditable="false" oe-keep-contenteditable="">Customer</t>, <br>
</t>
<t t-else="" data-oe-t-group-active="true" data-oe-t-selectable="true" data-oe-t-group="0" data-oe-t-inline="true">
<t t-out="object.partner_id.name or ''" data-oe-t-inline="true" contenteditable="false" oe-keep-contenteditable=""></t>, <br>
</t>

Odoo in the res_partner table has 5 types.

- Private
- Null (company)
- contact
- delivery
- other
- invoice

Related Posts Odgovori Prikazi Aktivnost
1
jul. 25
584
5
maj 25
17984
0
apr. 25
1009
1
apr. 25
1471
0
mar. 25
1312