[ADD] pages to pages listing

I don't see a good way to reverse `/page/<path:path>` for Website.page
during pages listing, so reintoduce explicit handling of that crap.

Ideally it would be possible to plug in new converters per db and
create some sort of PageConverte, *or* add a reverse operation to
controllers on top of converters (-> controller-specific url
generation even with un-generable converters).

bzr revid: xmo@openerp.com-20131112120814-ekt1rzlzj06pzypw
This commit is contained in:
Xavier Morel 2013-11-12 13:08:14 +01:00
parent 91ac20c28c
commit b1b29acd4b
1 changed files with 13 additions and 1 deletions

View File

@ -332,9 +332,21 @@ class website(osv.osv):
of the same.
:rtype: list({name: str, url: str})
"""
# FIXME: possibility to add custom converters without editing server
# would allow the creation of a pages converter generating page
# urls on its own
View = self.pool['ir.ui.view']
views = View.search_read(cr, uid, [['page', '=', True]],
fields=['name'], order='name', context=context)
xids = View.get_external_id(cr, uid, [view['id'] for view in views], context=context)
for view in views:
if xids[view['id']]:
yield {
'name': view['name'],
'url': '/page/' + xids[view['id']],
}
router = request.httprequest.app.get_db_router(request.db)
for rule in router.iter_rules():
if not self.rule_is_enumerable(rule):
continue