From c08b877370b24410bd33fad6d56899aa2eb6a7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 29 Apr 2013 11:33:29 +0200 Subject: [PATCH] [FIX] mail: fixed redirection action that was not redirecting to the discussion when failing to open the document. bzr revid: tde@openerp.com-20130429093329-w0qxiiipx1mkz6qt --- addons/mail/mail_mail.py | 11 ++------ addons/mail/mail_thread.py | 32 ++++++++++++---------- addons/portal/security/ir.model.access.csv | 2 +- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 6f02c31ecf6..9083c940027 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -198,14 +198,9 @@ class mail_mail(osv.Model): # mail_mail formatting, tools and send mechanism #------------------------------------------------------ - # TDE NOTE: as for 7.0 link generation is located in mail.mail because it grew - # based on a simple URL generation that moved towards something more complicated - # Moreover a bug in hierarchy generation prevents from putting link generation - # inside mail_thread and override it in modules; the overrides will not be - # taken into account - # TODO in 8.0: maybe factorize this to enable in modules link generation + # TODO in 8.0(+): maybe factorize this to enable in modules link generation # independently of mail_mail model - # TODO in 8.0: factorize doc name sanitized and 'Followers of ...' formatting + # TODO in 8.0(+): factorize doc name sanitized and 'Followers of ...' formatting # because it begins to appear everywhere def _get_partner_access_link(self, cr, uid, mail, partner=None, context=None): @@ -225,7 +220,7 @@ class mail_mail(osv.Model): 'message_id': mail.mail_message_id.id, }) url = urljoin(base_url, "?%s#%s" % (urlencode(query), urlencode(fragment))) - return _("""Access this document directly in OpenERP""") % url + return _("""Access your messages and documents in OpenERP""") % url else: return None diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 4af604891ac..1164e4ea273 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -494,21 +494,23 @@ class mail_thread(osv.AbstractModel): if not msg_id: return action msg = self.pool.get('mail.message').browse(cr, uid, msg_id, context=context) - if msg.model and msg.res_id and self.pool.get(msg.model).check_access_rights(cr, uid, 'read', raise_exception=False): - try: - model_obj = self.pool.get(msg.model) - model_obj.check_access_rule(cr, uid, [msg.res_id], 'read', context=context) - if not hasattr(model_obj, '_get_formview_action'): - action = self.pool.get('mail.thread')._get_formview_action(cr, uid, msg.res_id, model=msg.model, context=context) - else: - action = model_obj._get_formview_action(cr, uid, msg.res_id, context=context) - except (osv.except_osv, orm.except_orm): - action.update({ - 'context': { - 'search_default_model': msg.model, - 'search_default_res_id': msg.res_id, - } - }) + if msg.model and msg.res_id: + action.update({ + 'context': { + 'search_default_model': msg.model, + 'search_default_res_id': msg.res_id, + } + }) + if self.pool.get(msg.model).check_access_rights(cr, uid, 'read', raise_exception=False): + try: + model_obj = self.pool.get(msg.model) + model_obj.check_access_rule(cr, uid, [msg.res_id], 'read', context=context) + if not hasattr(model_obj, '_get_formview_action'): + action = self.pool.get('mail.thread')._get_formview_action(cr, uid, msg.res_id, model=msg.model, context=context) + else: + action = model_obj._get_formview_action(cr, uid, msg.res_id, context=context) + except (osv.except_osv, orm.except_orm): + pass return action #------------------------------------------------------ diff --git a/addons/portal/security/ir.model.access.csv b/addons/portal/security/ir.model.access.csv index 31bd7332c2f..26b0b4895e8 100644 --- a/addons/portal/security/ir.model.access.csv +++ b/addons/portal/security/ir.model.access.csv @@ -3,7 +3,7 @@ access_mail_message_portal,mail.message.portal,mail.model_mail_message,group_por access_mail_mail_portal,mail.mail.portal,mail.model_mail_mail,group_portal,1,1,1,0 access_mail_notification_portal,mail.notification.portal,mail.model_mail_notification,group_portal,1,1,1,0 access_mail_followers_portal,mail.followers.portal,mail.model_mail_followers,group_portal,1,1,0,0 -access_res_partner,res.partner,base.model_res_partner,portal.group_portal,1,0,0,0 +access_res_partner_portal,res.partner.portal,base.model_res_partner,portal.group_portal,1,0,0,0 access_acquirer,portal.payment.acquirer,portal.model_portal_payment_acquirer,,1,0,0,0 access_acquirer_all,portal.payment.acquirer,portal.model_portal_payment_acquirer,base.group_system,1,1,1,1 access_ir_attachment_group_portal,ir.attachment group_portal,base.model_ir_attachment,portal.group_portal,1,0,1,0 \ No newline at end of file