[FIX] various: get_access_action form one to multi
As this method is overided in several modules, the mix of new and old API makes it difficult to handle. Indeed in some cases we receive the expected dictionary, sometimes in a list, sometimes in a list of list, due to api.one decorator. This is a change in the method API, however it is currently completely buggy. Moreover this method is used internally and should not be used as an external API. Lastly, this method is new from v9.
This commit is contained in:
@@ -118,7 +118,7 @@ class MailController(http.Controller):
|
||||
if not record_sudo:
|
||||
# record does not seem to exist -> redirect to login
|
||||
return self._redirect_to_messaging()
|
||||
record_action = record_sudo.get_access_action()[0]
|
||||
record_action = record_sudo.get_access_action()
|
||||
|
||||
# the record has an URL redirection: use it directly
|
||||
if record_action['type'] == 'ir.actions.act_url':
|
||||
|
||||
@@ -245,10 +245,10 @@ class BlogPost(osv.Model):
|
||||
self._check_for_publication(cr, uid, ids, vals, context=context)
|
||||
return result
|
||||
|
||||
def get_access_action(self, cr, uid, id, context=None):
|
||||
def get_access_action(self, cr, uid, ids, context=None):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the post on the website directly """
|
||||
post = self.browse(cr, uid, id, context=context)
|
||||
post = self.browse(cr, uid, ids[0], context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/blog/%s/post/%s' % (post.blog_id.id, post.id),
|
||||
|
||||
@@ -704,10 +704,11 @@ class Post(models.Model):
|
||||
self._cr.execute("""UPDATE forum_post SET views = views+1 WHERE id IN %s""", (self._ids,))
|
||||
return True
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
def get_access_action(self):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the post on the website directly """
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/forum/%s/question/%s' % (self.forum_id.id, self.id),
|
||||
|
||||
@@ -7,10 +7,11 @@ from openerp import api, models
|
||||
class sale_order(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
def get_access_action(self):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the online quote if exists. """
|
||||
self.ensure_one()
|
||||
if self.state in ['draft', 'cancel']:
|
||||
return super(sale_order, self).get_access_action()
|
||||
return {
|
||||
|
||||
@@ -8,10 +8,11 @@ class Issue(models.Model):
|
||||
_name = "project.issue"
|
||||
_inherit = ['project.issue']
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
def get_access_action(self):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the post on the website directly """
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/my/issues/%s' % self.id,
|
||||
|
||||
@@ -253,12 +253,12 @@ class sale_order(osv.osv):
|
||||
products += line.product_id.product_tmpl_id.recommended_products(context=context)
|
||||
return products
|
||||
|
||||
def get_access_action(self, cr, uid, id, context=None):
|
||||
def get_access_action(self, cr, uid, ids, context=None):
|
||||
""" Override method that generated the link to access the document. Instead
|
||||
of the classic form view, redirect to the online quote if exists. """
|
||||
quote = self.browse(cr, uid, id, context=context)
|
||||
quote = self.browse(cr, uid, ids[0], context=context)
|
||||
if not quote.template_id:
|
||||
return super(sale_order, self).get_access_action(cr, uid, id, context=context)
|
||||
return super(sale_order, self).get_access_action(cr, uid, ids, context=context)
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': '/quote/%s' % quote.id,
|
||||
|
||||
+2
-2
@@ -1607,14 +1607,14 @@ class BaseModel(object):
|
||||
'context': context,
|
||||
}
|
||||
|
||||
def get_access_action(self, cr, uid, id, context=None):
|
||||
def get_access_action(self, cr, uid, ids, context=None):
|
||||
""" Return an action to open the document. This method is meant to be
|
||||
overridden in addons that want to give specific access to the document.
|
||||
By default it opens the formview of the document.
|
||||
|
||||
:param int id: id of the document to open
|
||||
"""
|
||||
return self.get_formview_action(cr, uid, id, context=context)
|
||||
return self.get_formview_action(cr, uid, ids[0], context=context)
|
||||
|
||||
def _view_look_dom_arch(self, cr, uid, node, view_id, context=None):
|
||||
return self.pool['ir.ui.view'].postprocess_and_fields(
|
||||
|
||||
Reference in New Issue
Block a user