summaryrefslogtreecommitdiff
path: root/addons/website/controllers/backend.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/controllers/backend.py')
-rw-r--r--addons/website/controllers/backend.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/website/controllers/backend.py b/addons/website/controllers/backend.py
index 3d75facfc30..d9ca7981612 100644
--- a/addons/website/controllers/backend.py
+++ b/addons/website/controllers/backend.py
@@ -31,6 +31,7 @@ class WebsiteBackend(http.Controller):
if has_group_designer:
config = request.env['res.config.settings'].sudo().create({})
+ config.website_id = current_website
if config.has_google_analytics_dashboard:
dashboard_data['dashboards']['visits'] = dict(
ga_client_id=config.google_management_client_id or '', # void string instead of stringified False
@@ -39,7 +40,7 @@ class WebsiteBackend(http.Controller):
return dashboard_data
@http.route('/website/dashboard/set_ga_data', type='json', auth='user')
- def website_set_ga_data(self, ga_client_id, ga_analytics_key):
+ def website_set_ga_data(self, website_id, ga_client_id, ga_analytics_key):
if not request.env.user.has_group('base.group_system'):
return {
'error': {
@@ -54,10 +55,14 @@ class WebsiteBackend(http.Controller):
'message': 'The Google Analytics Client ID or Key you entered seems incorrect.',
}
}
+ Website = request.env['website']
+ current_website = website_id and Website.browse(website_id) or Website.get_current_website()
+
request.env['res.config.settings'].create({
'has_google_analytics': True,
'has_google_analytics_dashboard': True,
'google_management_client_id': ga_client_id,
'google_analytics_key': ga_analytics_key,
+ 'website_id': current_website,
}).execute()
return True