diff --git a/document_page/models/document_page.py b/document_page/models/document_page.py index 91a0218e..4cfe4b42 100644 --- a/document_page/models/document_page.py +++ b/document_page/models/document_page.py @@ -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 = '{}'.format(self.backend_url, self.name) - if index: r += "" return r - @api.multi @api.depends('history_head') diff --git a/document_page/readme/CONTRIBUTORS.rst b/document_page/readme/CONTRIBUTORS.rst index 835f2d15..2061bdb5 100644 --- a/document_page/readme/CONTRIBUTORS.rst +++ b/document_page/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Iván Todorovich * Jose Maria Alzaga * Lois Rilo +* Simone Orsi diff --git a/document_page/tests/test_document_page.py b/document_page/tests/test_document_page.py index 4799843d..3a67f08e 100644 --- a/document_page/tests/test_document_page.py +++ b/document_page/tests/test_document_page.py @@ -47,3 +47,11 @@ class TestDocumentPage(common.TransactionCase): page.backend_url, '/web#id={}&model=document.page&view_type=form'.format(page.id) ) + menu = self.env.ref('knowledge.menu_document') + page.menu_id = menu + self.assertEqual( + page.backend_url, + '/web#id={}&model=document.page&view_type=form&action={}'.format( + page.id, menu.action.id + ) + )