0
votes

In Odoo 9 community outgoing email used to work (smtp configured, etc.), but now I get the following error when trying to send any email (invoice, internal note, etc.) from any account, for any template.

Things I changed since it worked that might (or might not) be linked to this issue:

  • I installed and uninstalled the SMTP Server Per User plugin
  • I changed the "from: " email address in the email templates

Any clue why this occurs? Or any clue what this "body" key is and where it is supposed to be defined? Thanks!

Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 605, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 642, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 893, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 471, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 998, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 986, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 369, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/wizard/mail_compose_message.py", line 191, in send_mail_action
    return self.send_mail()
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/account/models/account_invoice.py", line 1306, in send_mail
    return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/wizard/mail_compose_message.py", line 248, in send_mail
    ActiveModel.browse(res_id).message_post(message_type='comment', subtype=subtype, **mail_values)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_thread.py", line 1712, in message_post
    new_message = MailMessage.create(values)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_message.py", line 864, in create
    user_signature=self.env.context.get('mail_notify_user_signature', True))
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/mail_message.py", line 926, in _notify
    partners._notify(self, force_send=force_send, user_signature=user_signature)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/res_partner.py", line 127, in _notify
    ('notify_email', '!=', 'none')])._notify_by_email(message, force_send=force_send, user_signature=user_signature)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 236, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/mail/models/res_partner.py", line 178, in _notify_by_email
    new_emails, new_recipients_nbr = self._notify_send(not_values['body'], not_values['subject'], recipient_template_values['not_followers'], **base_mail_values)
KeyError: 'body'
2

2 Answers

1
votes

@v11 odoo community

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

When Other User sends message on contacts page it gives outgoing email KeyError: 'body'. This Error is occur from Mail Template : [mail module /data/ mail_data.xml]

so change Your Template Body code Or You Can Also inherit Mail Template:

  1. Remove extra content in this mail_data.xml file.

    % if ctx.get('website_url'):       
    % endif
    
  2. Only This code Work Properly :

    <p style="color: #555555;">
      Sent by
      % if ctx.get('website_url'):
        <a href="${ctx['website_url']}" style="text-decoration:none; color: #875A7B;">
      % endif
      ${ctx.get('company_name')}
      </a>
      using
      <a target="_blank" href="https://www.odoo.com" style="text-decoration:none; color: #875A7B;">Odoo</a>.
    </p>
    

Also Reference : https://i.stack.imgur.com/h8yMK.png

0
votes

I did not solve the issue myself, but the person who did told me it came from a translation file and an "<" sign that was interpreted as a smaller than in the python code. So he changed the translation file to remove the smaller than.