mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-19 03:42:19 -06:00
document_page: fix link
This commit is contained in:
committed by
Justine Doutreloux
parent
1ed4b34550
commit
79cf9a6f7a
@@ -101,6 +101,26 @@ class DocumentPage(models.Model):
|
||||
index=True,
|
||||
ondelete='cascade',
|
||||
)
|
||||
backend_url = fields.Char(
|
||||
string='Backend URL',
|
||||
help='Use it to link resources univocally',
|
||||
compute='_compute_backend_url',
|
||||
)
|
||||
|
||||
@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:
|
||||
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):
|
||||
@@ -116,8 +136,7 @@ class DocumentPage(models.Model):
|
||||
index += ["<li>" + subpage._get_page_index() + "</li>"]
|
||||
r = ''
|
||||
if link:
|
||||
r = '<a href="#id=%s">%s</a>' % (self.id, self.name)
|
||||
|
||||
r = '<a href="{}">{}</a>'.format(self.backend_url, self.name)
|
||||
if index:
|
||||
r += "<ul>" + "".join(index) + "</ul>"
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user