Merge lp:~openerp-dev/openobject-server/7.0-opw-591889-dhs into lp:openobject-server/7.0

Proposed by Dhruti Shastri(OpenERP)
Status: Merged
Merge reported by: Naresh(OpenERP)
Merged at revision: not available
Proposed branch: lp:~openerp-dev/openobject-server/7.0-opw-591889-dhs
Merge into: lp:openobject-server/7.0
Diff against target: 12 lines (+1/-1)
1 file modified
openerp/addons/base/ir/ir_attachment.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/7.0-opw-591889-dhs
Reviewer Review Type Date Requested Status
Thibault Delavallée (OpenERP) (community) Approve
Stefan Rijnhart (Opener) (community) Approve
Dhruti Shastri(OpenERP) (community) Needs Resubmitting
Naresh(OpenERP) Pending
Review via email: mp+160880@code.launchpad.net

Description of the change

AttributeError: 'NoneType' object has no attribute 'exists'
1. Messaging -> Inbox
2. Compose a new message
3. Add an attachment and then click on 'Send' button, It gives following traceback:

Server Traceback (most recent call last): File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/web/session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/netsvc.py", line 293, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/osv/osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/audittrail/audittrail.py", line 514, in execute_cr return fct_src(cr, uid, model, method, *args, **kw) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/purchase/purchase.py", line 1222, in send_mail return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/sale/sale.py", line 996, in send_mail return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/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 "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/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 "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/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 "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/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 "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/base_calendar/crm_meeting.py", line 160, in write return super(ir_attachment, self).write(cr, uid, ids, vals, context=context) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/document/document.py", line 129, in write return super(document_file, self).write(cr, uid, ids, vals, context) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/base/ir/ir_attachment.py", line 268, in write self.check(cr, uid, ids, 'write', context=context, values=vals) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/openerp/addons/document/document.py", line 76, in check return super(document_file, self).check(cr, uid, ids, mode='read', context=context, values=values) File "/home/odoo/runbot/static/openerp-dev-7-0-7739/server/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'

To post a comment you must log in.
Revision history for this message
hiren (hiren-6) wrote :

any update on this issue?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Please respect the PEP8 convention of adding a space after a comma.

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

I think this bug is pretty bad, it affects a core functionality of messaging/mailing, why has it taken so long to get fixed and merged? Why can't openerp push the fix and adjust for pep8, instead of waiting for the cosmetic pep8 adjustment, but in the mean time letting a huge bug in message/mailing stand there? This is rather shocking.

4961. By Dhruti Shastri(OpenERP)

[ir_attachment] : Composing message with attachement form Menu Messagine gives error (Case: 591889)

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) :
review: Needs Resubmitting
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for the change! Let's hope this gets picked up quickly by the core devs.

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

Can you mark this bug as high, to get it to better attention:
https://bugs.launchpad.net/openobject-server/+bug/1171457

I've linked to here, where the fix sits, hopefully with the bug marked as high, the diff will get merged quicker.

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

I'm still waiting for this one to get merged, it is approved, it is a big bug affecting a code functionality of messaging/mailing.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Hiren,

I share your frustration, but please don't hold your breath. OpenERP merge time is measured in months rather than days. It's a shame really.

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

Can this fix please be merged.

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

Can this fix please be merged, this bug breaks message attachments.

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.

Relevant proposal appears on the bug!

Hope this helps.

Corrections are invited.

Thanks.

Revision history for this message
Mohammed Shekha(Open ERP) (msh-openerp) wrote :

Hello Serpent CS,

I do agree, the issue is something else which is fixed in lp:~openerp-dev/openobject-addons/7.0-opw-591889-msh.

Reason and root issue: It is faced only if you compose a mail from "Compose a new message" button otherwise if you compose full email and opens same popup from small image on top right corner(open the mail composer) then you will not face this issue, even if you not use full mail composer popup and use simply message textarea the even also this will not be faced.
It is because the Mesaging is a client action and view mail.wall view, so everything is handled through mail web addons, only thing was missing is context, when you click on "Compose a new message" it calls action mail.compose.message but here forget to pass context, hence when it comes default_Get default_get will not have context value default_res_model and default_res_id so message_post method will not set res_model and res_id and so on...

I passed the context in branch lp:~openerp-dev/openobject-addons/7.0-opw-591889-msh which will fix this issue.

Thanks.

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

Hello,

For me it seems that both merge proposals are valid :
1/ avoid doing unnecessary queries in mail_thread.message_post()
2/ "'res_model' in values" is not the correct way to check if an attachment has a related document, as now res_model can effectively be False; values.get('res_model') seems better. Free attachments will be considered as available, as the rule about transferring access right on the related document can not apply to free attachments.

I am fixing it in saas-1, and will backport it in 7.0.

Thibault.

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

See comment on the bug; actually this merge proposal seems the correct one for me.

review: Approve
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

This was merge in 7.0 at revision 4991 (revid Revision ID: <email address hidden>).

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

with a bit modified

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_attachment.py'
2--- openerp/addons/base/ir/ir_attachment.py 2013-02-27 22:19:43 +0000
3+++ openerp/addons/base/ir/ir_attachment.py 2013-05-08 10:48:26 +0000
4@@ -198,7 +198,7 @@
5 continue
6 res_ids.setdefault(rmod,set()).add(rid)
7 if values:
8- if 'res_model' in values and 'res_id' in values:
9+ if values.get('res_model', False) and values.get('res_id', 0):
10 res_ids.setdefault(values['res_model'],set()).add(values['res_id'])
11
12 ima = self.pool.get('ir.model.access')