Server Action cannot send multiple E-mails

Bug #956898 reported by Serpent Consulting Services
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

Hello,

Here are the steps to reproduce this bug:

1 - Install hr_holidays module.
2 - Create new server action for 'hr.holidays' object and set action type email and set email address "object.employee_id.parent_id.user_id.user_email , object.employee_id.user_id.user_email".
3 - Assign this server action to 'confirm' workflow activity in hr.holidays workflow
4- Now create allocation request If I Press confirm button then generate following error.

Traceback (most recent call last):
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/osv/osv.py", line 196, in exec_workflow
    res = self.exec_workflow_cr(cr, uid, obj, method, *args)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/osv/osv.py", line 189, in exec_workflow_cr
    return wf_service.trg_validate(uid, obj, args[0], method, cr)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/wkf_service.py", line 124, in trg_validate
    res2 = instance.validate(cr, id, ident, signal)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/instance.py", line 48, in validate
    workitem.process(cr, witem, ident, signal, force_running, stack=stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 61, in process
    ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 176, in _split_test
    _join_test(cr, t[0], t[1], ident, stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 184, in _join_test
    create(cr,[activity], inst_id, ident, stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 41, in create
    process(cr, res, ident, stack=stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 53, in process
    result = _execute(cr, workitem, activity, ident, stack)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/workitem.py", line 111, in _execute
    res2 = wkf_expr.execute_action(cr, ident, workitem, activity)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/workflow/wkf_expr.py", line 64, in execute_action
    result = obj.run(cr, ident[0], [activity['action_id']], ctx)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/addons/base/ir/ir_actions.py", line 687, in run
    msg = ir_mail_server.build_email(email_from, [address], subject, body)
  File "/home/serpentcs/workspace/OpenERP/6.1/server/openerp/addons/base/ir/ir_mail_server.py", line 307, in build_email
    msg['To'] = encode_rfc2822_address_header(COMMASPACE.join(email_to))
TypeError: sequence item 0: expected string, tuple found

The attached merges for both 6.1 and trunk does the trick.
Thanks.
Serpent Consulting Services.

Related branches

summary: - Server Action cannot send multiple E-mail
+ Server Action cannot send multiple E-mails
description: updated
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → Fix Committed
Changed in openobject-server:
status: Fix Committed → Fix Released
Changed in openobject-server:
milestone: none → 7.0
Revision history for this message
Ray Carnes (rcarnes) wrote :

A similar problem is happening on 7.0 when a Sales Order is confirmed:

Traceback (most recent call last):
  File "/opt/openerp7/addons/mail/mail_mail.py", line 269, in send
    subtype_alternative = 'plain')
  File "/opt/openerp7/server/openerp/addons/base/ir/ir_mail_server.py", line 329, in build_email
    msg['To'] = encode_rfc2822_address_header(COMMASPACE.join(email_to))
TypeError: sequence item 0: expected string, bool found

Is this related or should I open a new bug?

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Ray,

You gave this bug a new life!

The traceback suggests email_to as boolean.

Does that mean a situation when there is no email found in partner address of concerned sale order?

I propose it should give a warning! (should code )

Thanks.

Revision history for this message
Ray Carnes (rcarnes) wrote :

You are correct.

Adding an email address stops that error, but produces another error:

2013-01-31 23:25:54,888 15167 ERROR RC_LS_Dev openerp.addons.base.ir.ir_mail_server: Mail delivery failed via SMTP server 'localhost'.
error: 111
Connection refused
Traceback (most recent call last):
  File "/opt/openerp7/server/openerp/addons/base/ir/ir_mail_server.py", line 459, in send_email
    smtp = self.connect(smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption or False, smtp_debug)
  File "/opt/openerp7/server/openerp/addons/base/ir/ir_mail_server.py", line 244, in connect
    connection = smtplib.SMTP(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 309, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 111] Connection refused
2013-01-31 23:25:54,910 15167 ERROR RC_LS_Dev openerp.addons.mail.mail_mail: failed sending mail.mail 3
Traceback (most recent call last):
  File "/opt/openerp7/addons/mail/mail_mail.py", line 271, in send
    mail_server_id=mail.mail_server_id.id, context=context)
  File "/opt/openerp7/server/openerp/addons/base/ir/ir_mail_server.py", line 473, in send_email
    raise MailDeliveryException(_("Mail delivery failed"), msg)
MailDeliveryException: (u'Mail delivery failed', u"Mail delivery failed via SMTP server 'localhost'.\nerror: 111\nConnection refused")

So it moves on and tries to email the order, but can't because localhost isn't a mail server.

Note that these errors for me are appearing in the log, not in the UI.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.