From cd0aab0789fe3c0f0acdf3df08f4b84d4f7f7012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Dec 2012 17:07:36 +0100 Subject: [PATCH] [FIX] mail.compose.message: fixed creation of message on its own profile (res_users -> res_partner). bzr revid: tde@openerp.com-20121212160736-wcas9ucgzkcm1o7f --- addons/mail/wizard/mail_compose_message.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 58066c6f2c2..8d3e9c6879a 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -90,6 +90,17 @@ class mail_compose_message(osv.TransientModel): for field in vals: if field in fields: result[field] = vals[field] + + # TDE HACK: as mailboxes used default_model='res.users' and default_res_id=uid + # (because of lack of an accessible pid), creating a message on its own + # profile may crash (res_users does not allow writing on it) + # Posting on its own profile works (res_users redirect to res_partner) + # but when creating the mail.message to create the mail.compose.message + # access rights issues may rise + # We therefore directly change the model and res_id + if result.get('model') == 'res.users' and result.get('res_id') == uid: + result['model'] = 'res.partner' + result['res_id'] = self.pool.get('res.users').browse(cr, uid, uid).partner_id.id return result def _get_composition_mode_selection(self, cr, uid, context=None):