Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5569 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

Works like a charm. Thanks Jainesh!

Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
1
lip 25
595
5
maj 25
17994
0
kwi 25
1011
1
kwi 25
1473
0
mar 25
1316