From 6183134f4d17c4534664e0a9e3da6ed6fb71113a Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 28 Nov 2012 16:47:17 +0100 Subject: [PATCH 1/5] [FIX] Attempt to fix mail bug, why the hell res_model is not in the values?. bzr revid: vta@openerp.com-20121128154717-3ashimdrwd0kl24k --- addons/mail/mail_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index ba6d101541c..ead17a89b77 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -583,7 +583,7 @@ class mail_message(osv.Model): if message.get('author_id') and message.get('author_id') == partner_id] elif operation == 'create': author_ids = [mid for mid, message in message_values.iteritems() - if not message.get('model') and not message.get('res_id')] + if not message.get('res_model') and not message.get('res_id')] else: author_ids = [] @@ -640,6 +640,7 @@ class mail_message(osv.Model): (self._description, operation)) def create(self, cr, uid, values, context=None): + values['model'] = context.get('default_res_model') if (context and context.get('default_res_model')) else '' if not values.get('message_id') and values.get('res_id') and values.get('model'): values['message_id'] = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values) elif not values.get('message_id'): From 616925f1139b5ec3e124bf416a240a3000d405dc Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Fri, 30 Nov 2012 12:12:23 +0100 Subject: [PATCH 2/5] [FIX] Fixed the context sent by the invite wizard. Also give the author the rigth to write. bzr revid: vta@openerp.com-20121130111223-49fpinmq82llt2cq --- addons/mail/mail_message.py | 3 +-- addons/mail/wizard/invite.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index ead17a89b77..d4edb7616e6 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -578,7 +578,7 @@ class mail_message(osv.Model): model_record_ids.setdefault(rmod, dict()).setdefault(rid, set()).add(id) # Author condition, for read and create (private message) -> could become an ir.rule, but not till we do not have a many2one variable field - if operation == 'read': + if operation == 'read' or operation == 'write': author_ids = [mid for mid, message in message_values.iteritems() if message.get('author_id') and message.get('author_id') == partner_id] elif operation == 'create': @@ -640,7 +640,6 @@ class mail_message(osv.Model): (self._description, operation)) def create(self, cr, uid, values, context=None): - values['model'] = context.get('default_res_model') if (context and context.get('default_res_model')) else '' if not values.get('message_id') and values.get('res_id') and values.get('model'): values['message_id'] = tools.generate_tracking_message_id('%(res_id)s-%(model)s' % values) elif not values.get('message_id'): diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index 50ecf9450da..c0fa410b87b 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -71,12 +71,14 @@ class invite_wizard(osv.osv_memory): # send an email if wizard.message: + ctx = dict(context) + ctx.update({'default_res_id': False}) for follower_id in new_follower_ids: mail_mail = self.pool.get('mail.mail') mail_id = mail_mail.create(cr, uid, { 'subject': 'Invitation to follow %s' % document.name_get()[0][1], 'body_html': '%s' % wizard.message, 'auto_delete': True, - }, context=context) + }, context=ctx) mail_mail.send(cr, uid, [mail_id], recipient_ids=[follower_id], context=context) return {'type': 'ir.actions.act_window_close'} From 04149ce60edd8d445651883dc74b417920327302 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Mon, 3 Dec 2012 12:01:31 +0100 Subject: [PATCH 3/5] [FIX] Fixed context, and added comments as per TDE suggestion. bzr revid: vta@openerp.com-20121203110131-suh6dc2y4gfsp933 --- addons/mail/mail_message.py | 3 ++- addons/mail/wizard/invite.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index edaaa3441f7..149ba7f8ccb 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -564,6 +564,7 @@ class mail_message(osv.Model): - uid have write access on the related document if model, res_id, OR - otherwise: raise - write: if + - author_id == pid, uid is the author, OR - uid has write access on the related document if model, res_id - Otherwise: raise - unlink: if @@ -591,7 +592,7 @@ class mail_message(osv.Model): if message.get('author_id') and message.get('author_id') == partner_id] elif operation == 'create': author_ids = [mid for mid, message in message_values.iteritems() - if not message.get('res_model') and not message.get('res_id')] + if not message.get('model') and not message.get('res_id')] else: author_ids = [] diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index c0fa410b87b..e2fe8bde272 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -71,14 +71,16 @@ class invite_wizard(osv.osv_memory): # send an email if wizard.message: - ctx = dict(context) - ctx.update({'default_res_id': False}) + # the invite wizard should create a private message not related to any object, + # we ensure that by removing default res_id and res_model from the context + context.pop('default_res_id') + context.pop('default_res_model') for follower_id in new_follower_ids: mail_mail = self.pool.get('mail.mail') mail_id = mail_mail.create(cr, uid, { 'subject': 'Invitation to follow %s' % document.name_get()[0][1], 'body_html': '%s' % wizard.message, 'auto_delete': True, - }, context=ctx) + }, context=context) mail_mail.send(cr, uid, [mail_id], recipient_ids=[follower_id], context=context) return {'type': 'ir.actions.act_window_close'} From 3268f93197dabff4c7f3b74f79a57d859bc47e8f Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Tue, 4 Dec 2012 09:39:35 +0100 Subject: [PATCH 4/5] [FIX] Pop the right context values, and give a default if not present. bzr revid: vta@openerp.com-20121204083935-pzye8yl1zlgthaik --- addons/mail/wizard/invite.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index e2fe8bde272..cd7e8b8c317 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -73,8 +73,8 @@ class invite_wizard(osv.osv_memory): if wizard.message: # the invite wizard should create a private message not related to any object, # we ensure that by removing default res_id and res_model from the context - context.pop('default_res_id') - context.pop('default_res_model') + context.pop('default_res_id', False) + context.pop('default_res_model', False) for follower_id in new_follower_ids: mail_mail = self.pool.get('mail.mail') mail_id = mail_mail.create(cr, uid, { From e3c7ae7e1d5ab2cde213300f7f5550d9826abdf0 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 5 Dec 2012 08:35:18 +0100 Subject: [PATCH 5/5] [FIX] Pop the correct field in context. bzr revid: vta@openerp.com-20121205073518-aokkreu26zdr03cc --- addons/mail/wizard/invite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py index cd7e8b8c317..e9335a7d983 100644 --- a/addons/mail/wizard/invite.py +++ b/addons/mail/wizard/invite.py @@ -74,7 +74,7 @@ class invite_wizard(osv.osv_memory): # the invite wizard should create a private message not related to any object, # we ensure that by removing default res_id and res_model from the context context.pop('default_res_id', False) - context.pop('default_res_model', False) + context.pop('default_model', False) for follower_id in new_follower_ids: mail_mail = self.pool.get('mail.mail') mail_id = mail_mail.create(cr, uid, {