Merge PR #218 into 12.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot 2019-07-16 07:56:32 +00:00
commit 74aebec1d8
7 changed files with 54 additions and 4 deletions

View File

@ -77,6 +77,7 @@ Contributors
* Iván Todorovich <ivan.todorovich@gmail.com>
* Jose Maria Alzaga <jose.alzaga@aselcis.com>
* Lois Rilo <lois.rilo@eficent.com>
* Simone Orsi <simone.orsi@camptocamp.com>
Other credits
~~~~~~~~~~~~~

View File

@ -4,7 +4,7 @@
{
'name': 'Document Page',
'version': '12.0.1.0.0',
'version': '12.0.1.1.0',
'category': 'Knowledge Management',
'author': 'OpenERP SA, Odoo Community Association (OCA)',
'images': [

View File

@ -45,6 +45,11 @@ msgstr ""
msgid "Author"
msgstr ""
#. module: document_page
#: model:ir.model.fields,field_description:document_page.field_document_page__backend_url
msgid "Backend URL"
msgstr ""
#. module: document_page
#: model_terms:ir.ui.view,arch_db:document_page.view_wiki_create_menu
msgid "Cancel"
@ -517,13 +522,18 @@ msgstr ""
msgid "Unread Messages Counter"
msgstr ""
#. module: document_page
#: model:ir.model.fields,help:document_page.field_document_page__backend_url
msgid "Use it to link resources univocally"
msgstr ""
#. module: document_page
#: model:ir.model,name:document_page.model_document_page_create_menu
msgid "Wizard Create Menu"
msgstr ""
#. module: document_page
#: code:addons/document_page/models/document_page.py:108
#: code:addons/document_page/models/document_page.py:128
#, python-format
msgid "You cannot create recursive categories."
msgstr ""

View File

@ -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

View File

@ -3,3 +3,4 @@
* Iván Todorovich <ivan.todorovich@gmail.com>
* Jose Maria Alzaga <jose.alzaga@aselcis.com>
* Lois Rilo <lois.rilo@eficent.com>
* Simone Orsi <simone.orsi@camptocamp.com>

View File

@ -426,6 +426,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;gmail.com">ivan.todorovich&#64;gmail.com</a>&gt;</li>
<li>Jose Maria Alzaga &lt;<a class="reference external" href="mailto:jose.alzaga&#64;aselcis.com">jose.alzaga&#64;aselcis.com</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">

View File

@ -37,3 +37,21 @@ class TestDocumentPage(common.TransactionCase):
})
page.content = 'New content'
self.assertIsNotNone(page.history_ids[0].diff)
def test_page_link(self):
page = self.page_obj.create({
'name': 'Test Page 3',
'content': 'Test content'
})
self.assertEqual(
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
)
)