Odoo Help

0

Display a text field in a mail template.

By
Yannick Gerard
on 5/6/15, 4:05 AM 980 views

Hello,

I created a mail template to explain to an employee why his leave was refused, but,when the mail is sent ...there is no explanation in it.

Here's my field, which is not empty (fill with a default function):

'refusal_explanation': fields.text('Refusal Explanation'), 

and here's my template:

<record id="email_template_conge_refused" model="email.template">
<field name="name">leave state - Refused</field>
<field name="email_from">openerp@cesbron.com</field>
<field name="subject">[what you asked] - Refused</field>
<field name="email_to">${object.employee_id.work_email}</field>
<field name="auto_delete" eval="True"/>
<field name="model_id" ref="cesbron_hr13.model_hr_holidays"/>
<field name="body_html"><![CDATA[
<p>Hello</p>
<p> Your leave from ${object.date_from} to ${object.date_to} was modified by your superior.</p>
<p> The state is now "REFUSED"!!</p>
 
<p>Explanation: ${object.refusal_explanation}</p>

<p>best regards,</p>
<p>${object.employee_id.parent_id.name}</p>
]]></field>
</record>

I know there is something in refusal_explanation, "you didn"t say please", but the result is:

Hello

your leave from .............

the state is now "REFUSED!!"

explanation:                          <= and here should be write "you didn't say please"

best regards

some name.


My field is in the current object and is not empty that's why i don't understand why it doesn't apear in the mail ( I tried with a fields.char too....didn't work)

Someone can explain me why or what can I do to resolve my problem ?


You have added the field to hr.holidays model right? Have you checked without default function? I mean by entering some text manually? May be problem with default function.

Akhil P Sivan
on 5/7/15, 12:23 AM

Yeah I tried manually too, and I have the same result. I can see my field content in the view, but not in the mail ...

Yannick Gerard
on 5/7/15, 3:24 AM

If you are trying to set a template for employee holiday table, then the model used is wrong. ()

Atchuthan - Technical Consultant, Sodexis Inc
on 5/7/15, 7:41 AM

hr_holidays.model_hr_holidays

Atchuthan - Technical Consultant, Sodexis Inc
on 5/7/15, 7:42 AM

Go to Settings --> Technical --> Email --> Template, Open your record, and check your value with Dynamic value builder and Preview in it.

Atchuthan - Technical Consultant, Sodexis Inc
on 5/7/15, 7:43 AM

No it's the right model ... thanks to your advices, it seems to be an other issue...the line "explanation:${object.refusal_explanation}" doesn't want to be added to my template ... so i deleted all my templates and re-update them ...and it still don't work >.

Yannick Gerard
on 5/7/15, 8:22 AM

OK i found my problem ...there was a "noupdate="1" "at the start of my file ... that's why the update wasn't done... how did i Miss that thing ...

Yannick Gerard
on 5/7/15, 8:50 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 5/6/15, 4:05 AM
Seen: 980 times
Last updated: 5/24/15, 5:48 PM