summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-02-21 14:01:19 +0100
committerfwi-odoo <fwi@odoo.com>2017-03-03 15:44:44 +0100
commiteb56b9bebc56dbcde8d7d1fad09aeae331de7c8f (patch)
tree3f8ca5badb5b514028bd99dc28372c1c29ea80f9
parent37394534495c8049431aa1cf855dbb422c9564a4 (diff)
[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'
-rw-r--r--addons/website/models/website.py8
1 files 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