Merge lp:~openerp-dev/openobject-addons/7.0-opw-591889-msh into lp:openobject-addons/7.0

Proposed by Mohammed Shekha(Open ERP)
Status: Rejected
Rejected by: Naresh(OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-591889-msh
Merge into: lp:openobject-addons/7.0
Diff against target: 25 lines (+6/-2)
1 file modified
mail/static/src/js/mail.js (+6/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-591889-msh
Reviewer Review Type Date Requested Status
Mohammed Shekha(Open ERP) (community) Needs Resubmitting
Thibault Delavallée (OpenERP) Pending
Review via email: mp+164716@code.launchpad.net

Description of the change

Hello,

Fixed the issue of AttributeError: 'NoneType' object has no attribute 'exists' when we compose a new mail with attachement from button Compose a new message on mail wall.

Demo:- Goto Messaging -> Click on Compose a new message, add attachment and the send, faced traceback.

Reason:- context not passed in action when compose a mail from "Compose a new message" button, hence not fetched in default_get and default_res_model and default_res_id not set due to which traceback faced.

Thanks.

To post a comment you must log in.
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Hello,

In mail_thread.message_post(), we want to attach manually added attachments (having mail.compose.message model) to the message's document (having in our case a False model). As we could have 'free' attachments in the 7.0 modeling of the communication, being able to write False as res_model is required.

The server fix has been merged into 7.0. This merge proposal is therefore not necessary anymore.

Best regards,

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

Hello Thibault,

Thanks for the review.

>>In mail_thread.message_post(), we want to attach manually added attachments (having mail.compose.message model) to the message's document (having in our case a False model).As we could have 'free' attachments in the 7.0 modeling of the communication, being able to write False as res_model is required.

Would you please explain me why we should have model free attachment ?, if it should be then I have one scenario.
Install document module, now compose message from Compose New Message button, now go to Settings -> Email -> Messages.
See you last message you just send, see there are no attachments available for this document, so for this res_model and res_id are required which we will get from context which I passed here, we already passed context in other places, open full mail composer through corner button("open full mail composer"), here context is passed res_model and res_id set according to context in ir.attachment, also tyr without full mail composer post your message with attachment context comes in send_mail.

If this is the case that we should set res_model and res_id to False then why we have passed default_model and default_res_id from action context, see mail_thread_view.xml.
one more thing I didn't get here why default_res_model is res.users, and default_res_id is uid, according to me res_model should be mail.message and res_id should be active_id, is ther any other use of this default_model and default_res_id ?

According to me context should be set in action called from mail.js and in mail_thread_view.xml default_res_model and default_res_id should be mail.message and active_id respectively, so when you post any message you can attahcment from header in Settings -> Email -> Mesages.

No doubt fix of revision 4991 in server will hide traceback but according to me actual problem is due to context.

Correct me if I am wrong.

Hope this will help.

Thanks.

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

Closing this as another fix has already been committed in 7.0 at revision 4991 (revid Revision ID: <email address hidden>).

Thanks,

Unmerged revisions

9142. By Mohammed Shekha<email address hidden>

[FIX]Fixed the issue of AttributeError: 'NoneType' object has no attribute 'exists' when we compose a new mail with attachement from button Compose a new message on mail wall.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mail/static/src/js/mail.js'
2--- mail/static/src/js/mail.js 2013-05-08 11:39:52 +0000
3+++ mail/static/src/js/mail.js 2013-05-20 12:22:39 +0000
4@@ -1949,6 +1949,11 @@
5 var self=this;
6 this.$(".oe_write_full").click(function (event) {
7 event.stopPropagation();
8+ context = {}
9+ if (self.context.default_model && self.context.default_res_id){
10+ context.default_model = self.context.default_model;
11+ context.default_res_id = self.context.default_res_id;
12+ }
13 var action = {
14 type: 'ir.actions.act_window',
15 res_model: 'mail.compose.message',
16@@ -1957,8 +1962,7 @@
17 action_from: 'mail.ThreadComposeMessage',
18 views: [[false, 'form']],
19 target: 'new',
20- context: {
21- },
22+ context: context,
23 };
24 session.client.action_manager.do_action(action);
25 });