[FIX] better handling of '/'. / is the first menu and not the first menu is /. Allows to move the first menu in another position

bzr revid: fp@tinyerp.com-20140511153235-6mmygt69z45rcx4r
This commit is contained in:
Fabien Pinckaers 2014-05-11 17:32:35 +02:00
parent 798e4156fa
commit cebce64b00
1 changed files with 7 additions and 4 deletions

View File

@ -34,15 +34,18 @@ class Website(openerp.addons.web.controllers.main.Home):
#------------------------------------------------------
@http.route('/', type='http', auth="public", website=True, multilang=True)
def index(self, **kw):
page = 'homepage'
try:
main_menu = request.registry['ir.model.data'].get_object(request.cr, request.uid, 'website', 'main_menu')
first_menu = main_menu.child_id and main_menu.child_id[0]
# Dont 302 loop on /
if first_menu and not ((first_menu.url == '/') or first_menu.url.startswith('/#') or first_menu.url.startswith('/?')):
return request.redirect(first_menu.url)
if first_menu:
if not (first_menu.startswith(('/page/', '/?', '/#')) or (first_menu=='/')):
return request.redirect(first_menu.url)
if first_menu.startswith('/page/'):
page = first_menu[6:]
except:
pass
return self.page("website.homepage")
return self.page(page)
@http.route(website=True, auth="public", multilang=True)
def web_login(self, *args, **kw):