[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
This commit is contained in:
Thibault Delavallée 2013-04-29 11:33:29 +02:00
parent 0691000b61
commit c08b877370
3 changed files with 21 additions and 24 deletions

View File

@ -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 _("""<small>Access this document <a style='color:inherit' href="%s">directly in OpenERP</a></small>""") % url
return _("""<small>Access your messages and documents <a style='color:inherit' href="%s">in OpenERP</a></small>""") % url
else:
return None

View File

@ -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
#------------------------------------------------------

View File

@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 access_mail_mail_portal mail.mail.portal mail.model_mail_mail group_portal 1 1 1 0
4 access_mail_notification_portal mail.notification.portal mail.model_mail_notification group_portal 1 1 1 0
5 access_mail_followers_portal mail.followers.portal mail.model_mail_followers group_portal 1 1 0 0
6 access_res_partner access_res_partner_portal res.partner res.partner.portal base.model_res_partner portal.group_portal 1 0 0 0
7 access_acquirer portal.payment.acquirer portal.model_portal_payment_acquirer 1 0 0 0
8 access_acquirer_all portal.payment.acquirer portal.model_portal_payment_acquirer base.group_system 1 1 1 1
9 access_ir_attachment_group_portal ir.attachment group_portal base.model_ir_attachment portal.group_portal 1 0 1 0