[IMP] website: res_config_setting make most key website specific

google analytics, google map api key, ... can be set by website

Remove useless duplicated label

Co-authored-by: Derie Romain <rde@odoo.com>
Co-authored-by: Kersten Jérémy <jke@odoo.com>
This commit is contained in:
Jeremy Kersten
2018-08-13 20:16:34 +02:00
co-authored by Derie Romain
parent 62d73253f3
commit 8300155cd6
10 changed files with 81 additions and 41 deletions
+11 -9
View File
@@ -28,24 +28,26 @@ class ResConfigSettings(models.TransientModel):
website_default_lang_code = fields.Char(
'Default language code', related='website_id.default_lang_code',
oldname='default_lang_code')
specific_user_account = fields.Boolean('Specific User Account', config_parameter='website_id.specific_user_account',
help='Are newly created user accounts website specific')
google_analytics_key = fields.Char('Google Analytics Key', related='website_id.google_analytics_key')
google_management_client_id = fields.Char('Google Client ID', related='website_id.google_management_client_id')
google_management_client_secret = fields.Char('Google Client Secret', related='website_id.google_management_client_secret')
cdn_activated = fields.Boolean('Use a Content Delivery Network (CDN)', related='website_id.cdn_activated')
cdn_activated = fields.Boolean(related='website_id.cdn_activated')
cdn_url = fields.Char(related='website_id.cdn_url')
cdn_filters = fields.Text(related='website_id.cdn_filters')
module_website_version = fields.Boolean("A/B Testing")
module_website_links = fields.Boolean(string="Link Trackers")
auth_signup_uninvited = fields.Selection(string="Customer Account", related='website_id.auth_signup_uninvited')
module_website_links = fields.Boolean("Link Trackers")
auth_signup_uninvited = fields.Selection("Customer Account", related='website_id.auth_signup_uninvited')
favicon = fields.Binary('Favicon', related='website_id.favicon')
# Set as global config parameter since methods using it are not website-aware. To be changed
# when multi-website is implemented
google_maps_api_key = fields.Char(string='Google Maps API Key', config_parameter='google_maps_api_key', default='')
has_google_analytics = fields.Boolean("Google Analytics", config_parameter='website.has_google_analytics')
has_google_analytics_dashboard = fields.Boolean("Embedded Google Analytics", config_parameter='website.has_google_analytics_dashboard')
has_google_maps = fields.Boolean("Google Maps", config_parameter='website.has_google_maps')
google_maps_api_key = fields.Char(related='website_id.google_maps_api_key')
has_google_analytics = fields.Boolean(related='website_id.has_google_analytics')
has_google_analytics_dashboard = fields.Boolean(related='website_id.has_google_analytics_dashboard')
has_google_maps = fields.Boolean(related='website_id.has_google_maps')
social_twitter = fields.Char(related='website_id.social_twitter')
social_facebook = fields.Char(related='website_id.social_facebook')
+1 -1
View File
@@ -18,7 +18,7 @@ class Partner(models.Model):
@api.multi
def google_map_img(self, zoom=8, width=298, height=298):
google_maps_api_key = self.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
google_maps_api_key = self.env['website'].get_current_website().google_maps_api_key
if not google_maps_api_key:
return False
params = {
+8 -3
View File
@@ -74,7 +74,7 @@ class Website(models.Model):
company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.ref('base.main_company').id)
language_ids = fields.Many2many('res.lang', 'website_lang_rel', 'website_id', 'lang_id', 'Languages', default=_active_languages)
default_lang_id = fields.Many2one('res.lang', string="Default Language", default=_default_language, required=True)
default_lang_code = fields.Char(related='default_lang_id.code', string="Default language code", store=True)
default_lang_code = fields.Char("Default language code", related='default_lang_id.code', store=True)
auto_redirect_lang = fields.Boolean('Autoredirect Language', default=True, help="Should users be redirected to their browser's language")
social_twitter = fields.Char('Twitter Account', default=_default_social_twitter)
@@ -88,8 +88,13 @@ class Website(models.Model):
google_management_client_id = fields.Char('Google Client ID')
google_management_client_secret = fields.Char('Google Client Secret')
google_maps_api_key = fields.Char('Google Maps API Key')
has_google_analytics = fields.Boolean("Google Analytics")
has_google_analytics_dashboard = fields.Boolean("Embedded Google Analytics")
has_google_maps = fields.Boolean("Google Maps")
user_id = fields.Many2one('res.users', string='Public User', required=True)
cdn_activated = fields.Boolean('Activate CDN for assets')
cdn_activated = fields.Boolean('Content Delivery Network (CDN)')
cdn_url = fields.Char('CDN Base URL', default='')
cdn_filters = fields.Text('CDN Filters', default=lambda s: '\n'.join(DEFAULT_CDN_FILTERS), help="URL matching those filters will be rewritten using the CDN Base URL")
partner_id = fields.Many2one(related='user_id.partner_id', relation='res.partner', string='Public Partner')
@@ -799,7 +804,7 @@ class Page(models.Model):
@api.multi
def _is_most_specific_page(self, page_to_test):
'''This will test if page_to_test is the most specific page in self.'''
pages_for_url = self.filtered(lambda page: page.url == page_to_test.url)
pages_for_url = self.sorted(key=lambda p: not p.website_id).filtered(lambda page: page.url == page_to_test.url)
# this works because pages are _order'ed by website_id
most_specific_page = pages_for_url[0]
@@ -481,6 +481,6 @@ body .modal {
}
}
.fa-check, .fa-eye-slash {
color: #00a09d;
color: $info;
}
}
@@ -53,12 +53,14 @@
<div t-name="website.ga_dialog_content">
Your Tracking ID: <input type="text" name="ga_analytics_key" placeholder="UA-XXXXXXXX-Y" t-att-value="ga_analytics_key" style="width: 100%"></input>
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics.html" class="fa fa-arrow-right" target="_blank">
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics.html" target="_blank">
<i class="fa fa-arrow-right"/>
How to get my Tracking ID
</a>
<br/><br/>
Your Client ID: <input type="text" name="ga_client_id" t-att-value="ga_key" style="width: 100%"></input>
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics_dashboard.html" class="fa fa-arrow-right" target="_blank">
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics_dashboard.html" target="_blank">
<i class="fa fa-arrow-right"/>
How to get my Client ID
</a>
</div>
@@ -72,7 +74,7 @@
</div>
<div class="btn-group pull-right" style="margin-right: 20px;">
<t t-foreach="widget.websites" t-as="website">
<button t-attf-class="btn btn-default js_website #{website.selected ? 'active' : ''}"
<button t-attf-class="btn btn-secondary js_website #{website.selected ? 'active' : ''}"
t-att-data-website-id="website.id">
<t t-esc="website.name"/>
</button>
@@ -18,9 +18,8 @@
<div class="text-muted">
Settings on this page will apply to this website
</div>
<field name="website_id" options="{'no_open': True, 'no_create_edit': True}"/>
<div>
<button name="website_go_to" type="object" string="Go to website"/>
<div class="mt16">
<field name="website_id" options="{'no_open': True, 'no_create_edit': True}"/>
</div>
</div>
</div>
@@ -63,7 +62,12 @@
<div class="text-muted">
Display this website when users visit this domain
</div>
<field name="website_domain"/>
<div class="mt16">
<field name="website_domain"/>
</div>
<div>
<button name="website_go_to" type="object" string="Go to website" class="btn-link" icon="fa-arrow-right"/>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="website_geoip_settings" groups="website.group_multi_website">
@@ -73,7 +77,9 @@
<div class="text-muted">
Display this website for users from these country groups
</div>
<field name="website_country_group_ids" widget="many2many_tags"/>
<div class="mt16">
<field name="website_country_group_ids" widget="many2many_tags"/>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="languages_setting">
@@ -117,7 +123,8 @@
</div>
<div attrs="{'invisible': [('has_google_analytics', '=', False)]}">
<a href="https://www.odoo.com/documentation/user/11.0/website/optimize/google_analytics.html"
class="oe_link fa fa-arrow-right" target="_blank">
class="oe_link" target="_blank">
<i class="fa fa-arrow-right"/>
How to get my Tracking ID
</a>
</div>
@@ -129,6 +136,7 @@
</div>
<div class="o_setting_right_pane">
<label for="has_google_analytics_dashboard"/>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted">
Follow your website traffic in Odoo.
</div>
@@ -144,7 +152,8 @@
</div>
<div attrs="{'invisible': [('has_google_analytics_dashboard', '=', False)]}">
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics_dashboard.html"
class="oe_link fa fa-arrow-right" target="_blank">
class="oe_link" target="_blank">
<i class="fa fa-arrow-right"/>
How to get my Client ID
</a>
</div>
@@ -156,6 +165,7 @@
</div>
<div class="o_setting_right_pane">
<label for="has_google_maps"/>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted">
Show your address on a map in the <a href="/contactus">Contact Us</a> page
</div>
@@ -166,8 +176,9 @@
</div>
</div>
<div attrs="{'invisible': [('has_google_maps', '=', False)]}">
<a role="button" class="btn-link fa fa-arrow-right" target="_blank"
<a role="button" class="btn-link" target="_blank"
href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,static_maps_backend&amp;keyType=CLIENT_SIDE&amp;reusekey=true">
<i class="fa fa-arrow-right"/>
Create a Google Project and Get a Key
</a>
</div>
@@ -184,7 +195,29 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="col-12 col-lg-6 o_setting_box" id="utm_tracker_settings" title="Analyze the efficiency of your marketing campaigns by using trackable UTM trackers (campaigns, medium, sources). Create trackers and follow clicks from the Promote menu of your website. Those trackers can be used in Google Analytics or in Odoo reports where you can see the opportunities and sales revenue generated thanks to your links.">
<div class="o_setting_left_pane">
<field name="module_website_links"/>
</div>
<div class="o_setting_right_pane">
<label for="module_website_links"/>
<div class="text-muted">
Track clicks on UTM links
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" groups="website.group_multi_website">
<div class="o_setting_left_pane">
<field name="specific_user_account"/>
</div>
<div class="o_setting_right_pane">
<label for="specific_user_account"/>
<div class="text-muted">
Force your user to create an account per website
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="auth_signup_uninvited_setting">
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
@@ -197,9 +230,7 @@
<field name="auth_signup_uninvited" class="o_light_label" widget="radio" required="True"/>
</div>
<div class="content-group">
<div class="mt16">
<button type="object" name="open_template_user" string="Default Access Rights" icon="fa-arrow-right" class="btn-link"/>
</div>
<button type="object" name="open_template_user" string="Default Access Rights" icon="fa-arrow-right" class="btn-link"/>
</div>
</div>
</div>
@@ -212,28 +243,28 @@
Add links to social media on your website
</div>
<div class="content-group">
<div class="row">
<label for="social_twitter" string="Twitter" class="col-md-3 o_light_label"/>
<div class="row mt16">
<label for="social_twitter" class="col-md-4 o_light_label"/>
<field name="social_twitter"/>
</div>
<div class="row">
<label for="social_facebook" string="Facebook" class="col-md-3 o_light_label"/>
<label for="social_facebook" class="col-md-4 o_light_label"/>
<field name="social_facebook"/>
</div>
<div class="row">
<label for="social_github" string="GitHub" class="col-md-3 o_light_label"/>
<label for="social_github" class="col-md-4 o_light_label"/>
<field name="social_github"/>
</div>
<div class="row">
<label for="social_linkedin" string="LinkedIn" class="col-md-3 o_light_label"/>
<label for="social_linkedin" class="col-md-4 o_light_label"/>
<field name="social_linkedin"/>
</div>
<div class="row">
<label for="social_youtube" string="YouTube" class="col-md-3 o_light_label"/>
<label for="social_youtube" class="col-md-4 o_light_label"/>
<field name="social_youtube"/>
</div>
<div class="row">
<label for="social_googleplus" string="Google Plus" class="col-md-3 o_light_label"/>
<label for="social_googleplus" class="col-md-4 o_light_label"/>
<field name="social_googleplus"/>
</div>
</div>
@@ -244,7 +275,7 @@
<field name="cdn_activated"/>
</div>
<div class="o_setting_right_pane">
<label for="cdn_activated" string="Content Delivery Network (CDN)"/>
<label for="cdn_activated"/>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted">
Use a CDN to optimize the availability of your website's content
@@ -296,7 +296,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
partners = partner_ids.sudo()
google_map_partner_ids = ','.join(str(p.id) for p in partners)
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
google_maps_api_key = request.website.google_maps_api_key
values = {
'countries': countries,
+1 -1
View File
@@ -116,7 +116,7 @@ class WebsiteCustomer(http.Controller):
partners = Partner.sudo().search(domain, offset=pager['offset'], limit=self._references_per_page)
google_map_partner_ids = ','.join(str(it) for it in partners.ids)
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
google_maps_api_key = request.website.google_maps_api_key
tags = Tag.search([('website_published', '=', True), ('partner_ids', 'in', partners.ids)], order='classname, name ASC')
tag = tag_id and Tag.browse(tag_id) or False
@@ -52,7 +52,7 @@ class GoogleMap(http.Controller):
else:
partner_url = '/partners/'
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
google_maps_api_key = request.website.google_maps_api_key
values = {
'partner_url': partner_url,
'partner_data': json.dumps(partner_data),
@@ -134,7 +134,7 @@ class WebsiteMembership(http.Controller):
count_members += len(free_partner_ids)
google_map_partner_ids = ",".join(str(it) for it in google_map_partner_ids)
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
google_maps_api_key = request.website.google_maps_api_key
partners = {p.id: p for p in Partner.sudo().browse(list(page_partner_ids))}