Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5588 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Works like a charm. Thanks Jainesh!

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
618
5
thg 5 25
18029
0
thg 4 25
1025
1
thg 4 25
1482
0
thg 3 25
1326