← Back to team overview

openerp-india team mailing list archive

[Bug 1103693] [NEW] [7.0] email_template crashes in send_mail if there is an attachment

 

Public bug reported:

If there is an email template with a report attached to it then this
template crashes in send_mail() method.

I traced it and it turns out the reason why it crashes is that send_mail() method iterates over attachments.iteritems() which implies that attachments is a dictionary. 
In fact the variable attachments is generated by generate_email() method where it is created as a list.

Here is the stack trace:
Client Traceback (most recent call last):
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/http.py", line 195, in dispatch
    response["result"] = method(self, **self.params)
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/controllers/main.py", line 1082, in call_button
    action = self._call_kw(req, model, method, args, {})
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/controllers/main.py", line 1070, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 43, in proxy
    result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 31, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 104, in send
    raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)


Server Traceback (most recent call last):
  File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 90, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/netsvc.py", line 289, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/service/web_services.py", line 614, in dispatch
    res = fn(db, uid, *params)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 169, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 123, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 179, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 166, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/wizard/stock_partial_picking.py", line 214, in do_partial
    stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
  File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 1358, in do_partial
    self.action_move(cr, uid, [pick.id], context=context)
  File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 900, in action_move
    context=context)
  File "/home/etsinko/work/OpenErp7.0/upsi_addons/mrp_prodlot_autosplit/stock.py", line 80, in action_done
    result = super(stock_move, self).action_done(cr, uid, ids, context)
  File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 2389, in action_done
    wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/wkf_service.py", line 55, in trg_write
    instance.update(cr, id, ident)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/instance.py", line 52, in update
    workitem.process(cr, witem, ident, stack=stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 60, in process
    ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 175, in _split_test
    _join_test(cr, t[0], t[1], ident, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 183, in _join_test
    create(cr,[activity], inst_id, ident, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 40, in create
    process(cr, res, ident, stack=stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 60, in process
    ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 175, in _split_test
    _join_test(cr, t[0], t[1], ident, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 183, in _join_test
    create(cr,[activity], inst_id, ident, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 40, in create
    process(cr, res, ident, stack=stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 52, in process
    result = _execute(cr, workitem, activity, ident, stack)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 110, in _execute
    res2 = wkf_expr.execute_action(cr, ident, workitem, activity)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/wkf_expr.py", line 63, in execute_action
    result = obj.run(cr, ident[0], [activity['action_id']], ctx)
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/addons/base/ir/ir_actions.py", line 611, in run
    eval(action.code, cxt, mode="exec", nocopy=True) # nocopy allows to return 'action'
  File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 3, in <module>
  File "/home/etsinko/work/OpenErp7.0/openerp/addons/email_template/email_template.py", line 378, in send_mail
    for fname, fcontent in attachments.iteritems():
AttributeError: 'list' object has no attribute 'iteritems'

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1103693

Title:
  [7.0] email_template crashes in send_mail if there is an attachment

Status in OpenERP Addons (modules):
  New

Bug description:
  If there is an email template with a report attached to it then this
  template crashes in send_mail() method.

  I traced it and it turns out the reason why it crashes is that send_mail() method iterates over attachments.iteritems() which implies that attachments is a dictionary. 
  In fact the variable attachments is generated by generate_email() method where it is created as a list.

  Here is the stack trace:
  Client Traceback (most recent call last):
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/http.py", line 195, in dispatch
      response["result"] = method(self, **self.params)
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/controllers/main.py", line 1082, in call_button
      action = self._call_kw(req, model, method, args, {})
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/controllers/main.py", line 1070, in _call_kw
      return getattr(req.session.model(model), method)(*args, **kwargs)
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 43, in proxy
      result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 31, in proxy_method
      result = self.session.send(self.service_name, method, *args)
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 104, in send
      raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)

  
  Server Traceback (most recent call last):
    File "/home/etsinko/work/OpenErp7.0/openerp/web/addons/web/session.py", line 90, in send
      return openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/netsvc.py", line 289, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/service/web_services.py", line 614, in dispatch
      res = fn(db, uid, *params)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 169, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 123, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 179, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/osv/osv.py", line 166, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/wizard/stock_partial_picking.py", line 214, in do_partial
      stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
    File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 1358, in do_partial
      self.action_move(cr, uid, [pick.id], context=context)
    File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 900, in action_move
      context=context)
    File "/home/etsinko/work/OpenErp7.0/upsi_addons/mrp_prodlot_autosplit/stock.py", line 80, in action_done
      result = super(stock_move, self).action_done(cr, uid, ids, context)
    File "/home/etsinko/work/OpenErp7.0/openerp/addons/stock/stock.py", line 2389, in action_done
      wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/wkf_service.py", line 55, in trg_write
      instance.update(cr, id, ident)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/instance.py", line 52, in update
      workitem.process(cr, witem, ident, stack=stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 60, in process
      ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 175, in _split_test
      _join_test(cr, t[0], t[1], ident, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 183, in _join_test
      create(cr,[activity], inst_id, ident, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 40, in create
      process(cr, res, ident, stack=stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 60, in process
      ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 175, in _split_test
      _join_test(cr, t[0], t[1], ident, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 183, in _join_test
      create(cr,[activity], inst_id, ident, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 40, in create
      process(cr, res, ident, stack=stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 52, in process
      result = _execute(cr, workitem, activity, ident, stack)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/workitem.py", line 110, in _execute
      res2 = wkf_expr.execute_action(cr, ident, workitem, activity)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/workflow/wkf_expr.py", line 63, in execute_action
      result = obj.run(cr, ident[0], [activity['action_id']], ctx)
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/addons/base/ir/ir_actions.py", line 611, in run
      eval(action.code, cxt, mode="exec", nocopy=True) # nocopy allows to return 'action'
    File "/home/etsinko/work/OpenErp7.0/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval
      return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
    File "", line 3, in <module>
    File "/home/etsinko/work/OpenErp7.0/openerp/addons/email_template/email_template.py", line 378, in send_mail
      for fname, fcontent in attachments.iteritems():
  AttributeError: 'list' object has no attribute 'iteritems'

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1103693/+subscriptions


Follow ups

References