[IMP] website: allow defining the module used for the xml_id

When a new page is created, we want to allow the definition of the xml_id
as 'website.XXX' in order to have clean url in the frontend and not always
take the same module name than the template module name. Since the page
with url 'page/website.XXX' are parsed by the website controller to be
displayed as 'page/XXX'.
e.g. in studio we create page on the fly and don't want url as:
'www.odoo.com/page/website_studio.XXX'
This commit is contained in:
fwi-odoo
2017-03-03 15:44:44 +01:00
parent 3739453449
commit eb56b9bebc
+6 -2
View File
@@ -205,12 +205,16 @@ class Website(models.Model):
#----------------------------------------------------------
@api.model
def new_page(self, name, template='website.default_page', ispage=True):
def new_page(self, name, template='website.default_page', ispage=True, namespace=None):
""" Create a new website page, and assign it a xmlid based on the given one
:param name : the name of the page
:param template : potential xml_id of the page to create
:param namespace : module part of the xml_id if none, the template module name is used
"""
template_module, dummy = template.split('.')
if namespace:
template_module = namespace
else:
template_module, dummy = template.split('.')
website_id = self._context.get('website_id')
# completely arbitrary max_length