[FIX] website: menus with null URL would throw an error on display

Before this commit, if a website.menu had a URL set to null, it would throw an
error when displaying that menu.
It is normally not possible to do so in v11 but after a migration, menus can be
empty. (eg: Using an empty menu to display a divider in a dropdown menu)

Now we return an empty url instead of an error
This commit is contained in:
Romain Derie
2018-01-11 12:49:18 +01:00
parent 88fe132a27
commit 32701aa512
+1 -1
View File
@@ -815,7 +815,7 @@ class Menu(models.Model):
url = self.page_id.sudo().url
else:
url = self.url
if not self.url.startswith('/'):
if url and not self.url.startswith('/'):
if '@' in self.url:
if not self.url.startswith('mailto'):
url = 'mailto:%s' % self.url