7.0/trunk : Attachment on compose message throws error!

Bug #1171457 reported by hiren
30
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Invalid
Medium
OpenERP's Framework R&D
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

1.
Compose a new message, add an attachment to the message, click send. (even on a brand new database).

2.
Stack trace below.

3.
Expected it to send.

4.
ubuntu server side, chrome client side.

5.
7.0-20130421-232434-1

------------
Server Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 90, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/sale/sale.py", line 996, in send_mail
    return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/account/account_invoice.py", line 1760, in send_mail
    return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/email_template/wizard/mail_compose_message.py", line 80, in send_mail
    return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/mail/wizard/mail_compose_message.py", line 259, in send_mail
    msg_id = active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype=subtype, context=context, **post_values)
  File "/usr/lib/pymodules/python2.7/openerp/addons/mail/mail_thread.py", line 1052, in message_post
    ir_attachment.write(cr, SUPERUSER_ID, filtered_attachment_ids, {'res_model': model, 'res_id': thread_id}, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_attachment.py", line 268, in write
    self.check(cr, uid, ids, 'write', context=context, values=vals)
  File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_attachment.py", line 208, in check
    mids = self.pool.get(model).exists(cr, uid, mids)
AttributeError: 'NoneType' object has no attribute 'exists'

Related branches

Revision history for this message
hiren (hiren-6) wrote :

In ir_attachment.py line 205 or thereabout, if I change it to this, I do not get a trace, but I'm not sure it is meant to behave like this:

        ima = self.pool.get('ir.model.access')
        for model, mids in res_ids.items():
            if not model:
                continue
            # ignore attachments that are not attached to a resource anymore when checking access rights
            # (resource was deleted but attachment was not)
            mids = self.pool.get(model).exists(cr, uid, mids)
            ima.check(cr, uid, model, mode)

where I added just the part to continue if the model is false.

Revision history for this message
Amit Bhavsar (Open ERP) (amb-openerp) wrote :

Hello,

I have check this Issue with latest trunk and face the problem while send mail. but I have faced the traceback little bit diffrence. and It's sort out with your patch. so I am confirming this Issue with medium Importance.

Thanks!

affects: openobject-addons → openobject-server
Changed in openobject-server:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
Revision history for this message
hiren (hiren-6) wrote :
Revision history for this message
hiren (hiren-6) wrote :

any update on this issue? I do not want to update production to a latest stable and hit this issue again. we have monkey patched our production 7 to work around this issue.

Revision history for this message
hiren (hiren-6) wrote :

why is this bug marked medium, not being able to attach files to outgoing mails is critical to the messaging and mailing functions.

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

Guys,

I believe, the attached proposal does not solve the problem, it just gets the traceback out of your way.

Rather than catching the bug and skipping it from the receiving end, we should better shut the root of the error.

It's obvious that the message will not be relevant to any model whatsoever (if its composed just as an email), so stands no logic to call the unnecessary write() and thus 5+ other methods.

The attached merge proposal might shed some light.

Hope this helps.

Corrections are invited.

Thanks.

Changed in openobject-server:
status: Confirmed → Fix Committed
summary: - attachment on compose message error
+ 7.0/trunk : Attachment on compose message error
summary: - 7.0/trunk : Attachment on compose message error
+ 7.0/trunk : Attachment on compose message throws error!
Changed in openobject-server:
status: Fix Committed → Confirmed
Changed in openobject-addons:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Hello,

Actually after looking at both merge proposals, the real bug lies in ir_attachment. We should not check for related document, if obvisouly there is no related attachment. Moreover, in mail_thread, we want to attach manually added attachments (having mail.compose.message model) to the message's document (having in our case a False model). We should be able to write res_model as False on an attachment as this is now supported and required by the mail module.

Therefore the correct fix seems to be the one fixing ir_attachment.

Best regards,

Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Fix landed in 7.0 at revision 4991 (revid Revision ID: <email address hidden>).

Changed in openobject-addons:
status: Fix Committed → Invalid
Changed in openobject-server:
status: Confirmed → Fix Released
Changed in openobject-addons:
milestone: none → 7.0
Changed in openobject-server:
milestone: none → 7.0
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.