Skip to Content
Menu
This question has been flagged
5 Replies
8570 Views

Hi, I am running a Odoo10 community. I get an error when I try to send emails to contacts. Sending online proposals work though. Heres the traceback. Any tips on what I can do to correct it?

Traceback (most recent call last):

  File "/odoo/odoo-server/odoo/http.py", line 638, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/odoo/odoo-server/odoo/http.py", line 675, in dispatch result = self._call_function(**self.params) File "/odoo/odoo-server/odoo/http.py", line 331, in _call_function return checked_call(self.db, *args, **kwargs) File "/odoo/odoo-server/odoo/service/model.py", line 119, in wrapper return f(dbname, *args, **kwargs) File "/odoo/odoo-server/odoo/http.py", line 324, in checked_call result = self.endpoint(*a, **kw) File "/odoo/odoo-server/odoo/http.py", line 933, in __call__ return self.method(*args, **kw) File "/odoo/odoo-server/odoo/http.py", line 504, in response_wrap response = f(*args, **kw) File "/odoo/odoo-server/addons/web/controllers/main.py", line 862, in call_kw return self._call_kw(model, method, args, kwargs) File "/odoo/odoo-server/addons/web/controllers/main.py", line 854, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/odoo/odoo-server/odoo/api.py", line 681, in call_kw return call_kw_multi(method, model, args, kwargs) File "/odoo/odoo-server/odoo/api.py", line 672, in call_kw_multi result = method(recs, *args, **kwargs) File "/odoo/odoo-server/addons/mail/models/mail_thread.py", line 1878, in message_post new_message = MailMessage.create(values) File "/odoo/odoo-server/addons/mail/models/mail_message.py", line 722, in create user_signature=self.env.context.get('mail_notify_user_signature', True)) File "/odoo/odoo-server/addons/mail/models/mail_message.py", line 790, in _notify partners._notify(self, force_send=force_send, send_after_commit=send_after_commit, user_signature=user_signature) File "/odoo/odoo-server/addons/mail/models/res_partner.py", line 156, in _notify ('notify_email', '!=', 'none')])._notify_by_email(message, force_send=force_send, send_after_commit=send_after_commit, user_signature=user_signature) File "/odoo/odoo-server/addons/mail/models/res_partner.py", line 201, in _notify_by_email new_emails, new_recipients_nbr = self._notify_send(fol_values['body'], fol_values['subject'], recipient_template_values['followers'], **base_mail_values)KeyError: 'body'

Avatar
Discard
Author

Thank you @mahmoud. I figured it out. It was a faulty "string" in the email template config. I actually removed the existing config, saved, restarted and added the exact config, rebooted (for some reason) and it magically worked.

Best Answer

I'm having exactly the same problem. If I select a contact and try and send them a message using the 'out of the box' template 'partner mass mail' I get a server error ending wih

  File "/opt/ / /addons/mail/models/res_partner.py", line 206, in _notify_by_email
    new_emails, new_recipients_nbr = self._notify_send(fol_values['body'], fol_values['subject'], recipient_template_values['followers'], **base_mail_values)
KeyError: 'body'

I've created another template with an email body. I only have one language (english) so translation tables to update. Given I've seen this reported multiple times with either no answers or answers I don't understand, can anyone shine a light on this. I have two instances of Odoo, an Enterprise and Community and they both have the same problem.

Thanks in advance!

Avatar
Discard

I fixed it as follows (Odoo 11 CE)

Activate Developer mode

Under Settings > Mail Template, open template "Notification EMail"

Click Edit

Click the button for Code view

remove all the code and replace with something very simple such as:

<p style="color: #555555;">

Email sent by

</p>

Save

Test by sending the contact a message. It worked, and the mail was sent without errors.

I then went back to the Notification Email template, edited it, selected the code view again, and pasted in the code from the English version of the template.

That code, in case you need it, is as follows for 11CE:

<p>

% set company = ctx.get('company', user.company_id)

</p><div>

% if ctx.get('has_button_access'):

<div itemscope="" itemtype="http://schema.org/EmailMessage">

<div itemprop="potentialAction" itemscope="" itemtype="http://schema.org/ViewAction">

<link itemprop="target" href="${ctx['button_access']['url']}">

<link itemprop="url" href="${ctx['button_access']['url']}">

<meta itemprop="name" content="View ${ctx['model_name']}">

</div>

</div>

% endif

% if not ctx['is_discussion'] or not len(ctx['actions']) == 0 or ctx.get('has_button_access'):

<div summary="o_mail_notification" style="padding: 0px; width:600px;">

<table style="border-spacing:0px;width: 600px; margin-top: 5px;" cellspacing="0" cellpadding="0" border="0">

<tbody><tr>

<td valign="center">

% if ctx.get('has_button_access'):

<a href="${ctx['button_access']['url']}" style="padding: 8px 12px; font-size: 12px; color: #FFFFFF; text-decoration: none !important; font-weight: 400; background-color: #875A7B; border: 0px solid #875A7B; border-radius:3px">${ctx['button_access']['title']}</a>

% endif

% if ctx.get('has_button_follow'):

% if ctx.get('has_button_access'):

|

% endif

<a href="${ctx['button_follow']['url']}" style="color: #875A7B; text-decoration: none !important;">${ctx['button_follow']['title']}</a>

% elif ctx.get('has_button_unfollow'):

% if ctx.get('has_button_access'):

|

% endif

<a href="${ctx['button_unfollow']['url']}" style="color: #875A7B; text-decoration: none !important;">${ctx['button_unfollow']['title']}</a>

% endif

% if ctx.get('actions'):

% for action in ctx['actions']:

|

<a href="${action['url']}" style="color: #875A7B; !important;">${action['title']}</a>

% endfor

% endif

</td>

<td valign="center" align="right">

<img src="/logo.png?company=${company.id}" style="border-style:none;border-image-width:1;border-image-source:none;border-image-slice:100%;border-image-repeat:stretch;border-image-outset:0;border-left-color:currentcolor;border-bottom-color:currentcolor;border-right-color:currentcolor;border-top-color:currentcolor;padding: 0px; margin: 0px; height: auto; max-width: 80px; max-height: 40px;" alt="${company.name}">

</td>

</tr>

<tr>

<td colspan="2" style="text-align:center;">

<hr style="border-style:solid none none none;border-image-width:1;border-image-source:none;border-image-slice:100%;border-image-repeat:stretch;border-image-outset:0;border-left-color:currentcolor;border-bottom-color:currentcolor;border-right-color:currentcolor;background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:10px 0;" width="100%">

% if ctx.get('subtype') and ctx.get('subtype').internal:

<p style="background-color: #f2dede; padding: 5px; margin-bottom: 16px;">

<strong>Internal communication</strong>: Replying will post an internal note. Followers won't receive any email notification.

</p>

% endif

</td>

</tr>

</tbody></table>

</div>

% endif

<div>

${object.body | safe}

</div>

% if ctx.get('tracking'):

<ul>

% for tracking in ctx['tracking']

<li>${tracking[0]} : ${tracking[1]} -&gt; ${tracking[2]}</li>

% endfor

</ul>

% endif

% if ctx.get('signature'):

${ctx['signature'] | safe}

% endif

<br><p></p><p>

</p><p style="color: #555555;">

Sent by

% if ctx.get('website_url'):

<a href="${ctx['website_url']}" style=" color: #875A7B;">

% endif

${ctx.get('company_name')}

% if ctx.get('website_url'):

</a>

% endif

using

<a target="_blank" href="https://www.odoo.com" style=" color: #875A7B;">Odoo</a>.

</p>

</div><p></p>

Best Answer

Hi Alexander,

Which email template is it? I cannot figure it out.

Thank you

Avatar
Discard

Hi, it's the one called "Notification Email" with field "Applies to" = Message.

Best Answer

@v11 odoo community

Solved Error : Odoo - outgoing email KeyError: 'body'

Also Reference: https://stackoverflow.com/questions/39364364/odoo-outgoing-email-keyerror-body/47993347#47993347

Avatar
Discard
Best Answer

The problem in body of the email, may be empty , Check it

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 19
3764
3
Jan 17
3253
8
May 17
6225
2
Jul 24
609
1
May 24
1207