mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-22 13:22:19 -06:00
document_page: improve link using menu
This commit is contained in:
@@ -107,11 +107,20 @@ class DocumentPage(models.Model):
|
||||
compute='_compute_backend_url',
|
||||
)
|
||||
|
||||
@api.depends()
|
||||
@api.depends('menu_id', 'parent_id.menu_id')
|
||||
def _compute_backend_url(self):
|
||||
tmpl = '/web#id={}&model=document.page&view_type=form'
|
||||
for rec in self:
|
||||
rec.backend_url = tmpl.format(rec.id)
|
||||
url = tmpl.format(rec.id)
|
||||
# retrieve action
|
||||
action = None
|
||||
parent = rec
|
||||
while not action and parent:
|
||||
action = parent.menu_id.action
|
||||
parent = parent.parent_id
|
||||
if action:
|
||||
url += '&action={}'.format(action.id)
|
||||
rec.backend_url = url
|
||||
|
||||
@api.constrains('parent_id')
|
||||
def _check_parent_id(self):
|
||||
@@ -128,11 +137,9 @@ class DocumentPage(models.Model):
|
||||
r = ''
|
||||
if link:
|
||||
r = '<a href="{}">{}</a>'.format(self.backend_url, self.name)
|
||||
|
||||
if index:
|
||||
r += "<ul>" + "".join(index) + "</ul>"
|
||||
return r
|
||||
|
||||
|
||||
@api.multi
|
||||
@api.depends('history_head')
|
||||
|
||||
Reference in New Issue
Block a user