[FIX] mail, portal_sale: conserve action in /mail/view
Methods get_formview_action can be called by sudo() so for knowing the real user they should prefer context['uid'] to uid. Without the action `/web` can't figure out that e.g the view we want is the one for portal user and not the default one. With this fix, portal user (not in base.group_user) get to the intended view with the intended menu when clicking on a invoice/sale order portal mail link. As for other user there is no change. closes #10681 opw-666260
This commit is contained in:
@@ -143,6 +143,7 @@ class MailController(http.Controller):
|
||||
'id': res_id,
|
||||
'active_id': res_id,
|
||||
'view_id': record_sudo.get_formview_id(),
|
||||
'action': record_action.get('id'),
|
||||
}
|
||||
url = '/web?%s#%s' % (url_encode(query), url_encode(url_params))
|
||||
return werkzeug.utils.redirect(url)
|
||||
|
||||
@@ -41,7 +41,8 @@ class sale_order(osv.Model):
|
||||
)[document.partner_id.id]
|
||||
|
||||
def get_formview_action(self, cr, uid, id, context=None):
|
||||
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
|
||||
context = context or {}
|
||||
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, context.get('uid', uid), context=context)
|
||||
if user.share:
|
||||
document = self.browse(cr, uid, id, context=context)
|
||||
action_xmlid = 'action_quotations_portal' if document.state in ('draft', 'sent') else 'action_orders_portal'
|
||||
@@ -83,7 +84,8 @@ class account_invoice(osv.Model):
|
||||
)[document.partner_id.id]
|
||||
|
||||
def get_formview_action(self, cr, uid, id, context=None):
|
||||
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
|
||||
context = context or {}
|
||||
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, context.get('uid', uid), context=context)
|
||||
if user.share:
|
||||
return self.pool['ir.actions.act_window'].for_xml_id(cr, uid, 'portal_sale', 'portal_action_invoices', context=context)
|
||||
return super(account_invoice, self).get_formview_action(cr, uid, id, context=context)
|
||||
|
||||
Reference in New Issue
Block a user