From eb56b9bebc56dbcde8d7d1fad09aeae331de7c8f Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 21 Feb 2017 14:01:19 +0100 Subject: [PATCH] [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' --- addons/website/models/website.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 7d3a57d9317..db918401eed 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -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