summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2019-11-25 15:25:11 +0000
committerJeremy Kersten <jke@odoo.com>2019-12-17 17:07:30 +0000
commit546f3cac3f09799c634d72bd975ad77a192d36e1 (patch)
tree035b5522fdb5c54aaa93d2776d364c43a7739f4d
parent7921616aeaf0b18ffe598c2bf20b62e6f235d757 (diff)
[IMP] website: redo res config settings
task-2088625 closes odoo/odoo#40715 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
-rw-r--r--addons/website/controllers/main.py2
-rw-r--r--addons/website/models/res_config_settings.py18
-rw-r--r--addons/website/views/res_config_settings_views.xml81
-rw-r--r--addons/website/wizard/website_robots.xml2
-rw-r--r--addons/website_form/__manifest__.py1
-rw-r--r--addons/website_form/controllers/main.py6
-rw-r--r--addons/website_form/models/models.py7
-rw-r--r--addons/website_form/views/res_config_view.xml23
8 files changed, 45 insertions, 95 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index b3b3d8a0eea..687f49e919b 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -127,7 +127,7 @@ class Website(Home):
fields = country.get_address_fields()
return dict(fields=fields, states=[(st.id, st.name, st.code) for st in country.state_ids], phone_code=country.phone_code)
- @http.route(['/robots.txt'], type='http', auth="public", website=True)
+ @http.route(['/robots.txt'], type='http', auth="public", website=True, sitemap=False)
def robots(self, **kwargs):
return request.render('website.robots', {'url_root': request.httprequest.url_root}, mimetype='text/plain')
diff --git a/addons/website/models/res_config_settings.py b/addons/website/models/res_config_settings.py
index 18782c57854..85449fd23c2 100644
--- a/addons/website/models/res_config_settings.py
+++ b/addons/website/models/res_config_settings.py
@@ -4,6 +4,7 @@
from ast import literal_eval
from odoo import api, fields, models
+from odoo.exceptions import UserError
from odoo.tools.translate import _
@@ -36,10 +37,7 @@ class ResConfigSettings(models.TransientModel):
cdn_activated = fields.Boolean(related='website_id.cdn_activated', readonly=False)
cdn_url = fields.Char(related='website_id.cdn_url', readonly=False)
cdn_filters = fields.Text(related='website_id.cdn_filters', readonly=False)
- module_website_version = fields.Boolean("A/B Testing")
- module_website_links = fields.Boolean("Link Trackers")
- auth_signup_uninvited = fields.Selection(compute="_compute_auth_signup",
- inverse="_set_auth_signup")
+ auth_signup_uninvited = fields.Selection(compute="_compute_auth_signup", inverse="_set_auth_signup")
social_twitter = fields.Char(related='website_id.social_twitter', readonly=False)
social_facebook = fields.Char(related='website_id.social_facebook', readonly=False)
@@ -92,6 +90,10 @@ class ResConfigSettings(models.TransientModel):
self.has_google_maps = bool(self.google_maps_api_key)
@api.depends('website_id')
+ def has_default_share_image(self):
+ self.has_default_share_image = bool(self.social_default_image)
+
+ @api.depends('website_id')
def has_google_search_console(self):
self.has_google_search_console = bool(self.google_search_console)
@@ -113,10 +115,15 @@ class ResConfigSettings(models.TransientModel):
if not self.has_google_search_console:
self.google_search_console = False
+ def inverse_has_default_share_image(self):
+ if not self.has_default_share_image:
+ self.social_default_image = False
+
has_google_analytics = fields.Boolean("Google Analytics", compute=has_google_analytics, inverse=inverse_has_google_analytics)
has_google_analytics_dashboard = fields.Boolean("Google Analytics Dashboard", compute=has_google_analytics_dashboard, inverse=inverse_has_google_analytics_dashboard)
has_google_maps = fields.Boolean("Google Maps", compute=has_google_maps, inverse=inverse_has_google_maps)
has_google_search_console = fields.Boolean("Console Google Search", compute=has_google_search_console, inverse=inverse_has_google_search_console)
+ has_default_share_image = fields.Boolean("Use a image by default for sharing", compute=has_default_share_image, inverse=inverse_has_default_share_image)
@api.onchange('language_ids')
def _onchange_language_ids(self):
@@ -172,7 +179,8 @@ class ResConfigSettings(models.TransientModel):
def action_ping_sitemap(self):
if not self.website_id._get_http_domain():
- raise Warning(_("You don't have defined your domain"))
+ raise UserError(_("You haven't defined your domain"))
+
return {
'type': 'ir.actions.act_url',
'url': 'http://www.google.com/ping?sitemap=%s/sitemap.xml' % self.website_id._get_http_domain(),
diff --git a/addons/website/views/res_config_settings_views.xml b/addons/website/views/res_config_settings_views.xml
index d4fcecfcd33..6a32d2b55a7 100644
--- a/addons/website/views/res_config_settings_views.xml
+++ b/addons/website/views/res_config_settings_views.xml
@@ -105,43 +105,17 @@
<div class="mt8">
<field name="website_domain" placeholder="www.odoo.com"/>
</div>
- <div class="mt8 text-muted" title="You can have 2 websites with same domain AND a condition on country group to select wich website use.">
- Once the selection of available websites by domain is done, you can filter by country group.
- </div>
- <div class="mt8">
- <field name="website_country_group_ids" widget="many2many_tags"/>
- </div>
- </div>
- </div>
- <div class="col-12 col-lg-6 o_setting_box" id="auth_signup_uninvited_setting"
- title=" To send invitations in B2B mode, open a contact or select several ones in list view and click on 'Portal Access Management' option in the dropdown menu *Action*.">
- <div class="o_setting_left_pane">
- </div>
- <div class="o_setting_right_pane">
- <label for="auth_signup_uninvited"/>
- <span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
- <div class="text-muted">
- Let your customers log in to see their documents
- </div>
- <div class="mt8">
- <field name="auth_signup_uninvited" class="o_light_label" widget="radio" required="True"/>
- </div>
- <div class="mt8 content-group">
- <button type="object" name="open_template_user" string="Default Access Rights" icon="fa-arrow-right" class="btn-link"/>
- </div>
- </div>
- </div>
- <div class="col-12 col-lg-6 o_setting_box" id="website_logo_setting">
- <div class="o_setting_right_pane">
- <label for="website_logo"/>
- <span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
- <div class="text-muted">
- Display this logo on the website.
+ <div groups="base.group_no_one">
+ <div class="mt8 text-muted" title="You can have 2 websites with same domain AND a condition on country group to select wich website use.">
+ Once the selection of available websites by domain is done, you can filter by country group.
+ </div>
+ <div class="mt8">
+ <field name="website_country_group_ids" widget="many2many_tags"/>
+ </div>
</div>
- <field name="website_logo" widget="image" class="w-25 mt-2"/>
</div>
</div>
- <div class="col-12 col-lg-6 o_setting_box" id="force_account_per_website_setting" groups="website.group_multi_website">
+ <div class="col-12 col-lg-6 o_setting_box" id="specific_user_account_setting" groups="website.group_multi_website">
<div class="o_setting_left_pane">
<field name="specific_user_account"/>
</div>
@@ -219,30 +193,22 @@
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="social_default_image_setting">
+ <div class="o_setting_left_pane">
+ <field name="has_default_share_image"/>
+ </div>
<div class="o_setting_right_pane">
- <label string="Default Social Share Image" for="social_default_image"/>
+ <label string="Default Social Share Image" for="has_default_share_image"/>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
- <div class="text-muted">
+ <div class="text-muted" attrs="{'invisible': [('has_default_share_image', '=', False)]}">
If set, replaces the company logo as the default social share image.
</div>
- <field name="social_default_image" widget="image" class="w-25 mt-2"/>
+ <field name="social_default_image" widget="image" class="w-25 mt-2" attrs="{'invisible': [('has_default_share_image', '=', False)]}"/>
</div>
</div>
</div>
<h2>Features</h2>
<div class="row mt16 o_settings_container" id="webmaster_settings">
- <div id="multi_website" class="col-12 col-md-6 o_setting_box">
- <div class="o_setting_left_pane">
- <field name="group_multi_website"/>
- </div>
- <div class="o_setting_right_pane">
- <label string="Multi-Website" for="group_multi_website"/>
- <div class="text-muted">
- Manage multiple websites
- </div>
- </div>
- </div>
<div class="col-12 col-lg-6 o_setting_box" id="google_maps_setting">
<div class="o_setting_left_pane">
<field name="has_google_maps"/>
@@ -268,14 +234,21 @@
</div>
</div>
</div>
- <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="col-12 col-lg-6 o_setting_box" id="auth_signup_uninvited_setting"
+ title=" To send invitations in B2B mode, open a contact or select several ones in list view and click on 'Portal Access Management' option in the dropdown menu *Action*.">
<div class="o_setting_left_pane">
- <field name="module_website_links"/>
</div>
<div class="o_setting_right_pane">
- <label for="module_website_links"/>
+ <label for="auth_signup_uninvited"/>
+ <span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted">
- Track clicks on UTM links
+ Let your customers log in to see their documents
+ </div>
+ <div class="mt8">
+ <field name="auth_signup_uninvited" class="o_light_label" widget="radio" required="True"/>
+ </div>
+ <div class="mt8 content-group">
+ <button type="object" name="open_template_user" string="Default Access Rights" icon="fa-arrow-right" class="btn-link"/>
</div>
</div>
</div>
@@ -367,7 +340,7 @@
<span class="o_form_label">Robots.txt</span>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted">
- Robots.txt: Tells to search engine crawlers which pages or files the crawler can or can't request from your site.<br/>
+ Robots.txt: This file tells to search engine crawlers which pages or files they can or can't request from your site.<br/>
</div>
<div class="mt4">
<button type="object" name="action_open_robots" string="Edit robots.txt" class="btn-link" icon="fa-android"/>
@@ -379,7 +352,7 @@
<span class="o_form_label">Sitemap</span>
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
<div class="text-muted mt8">
- Sitemap.xml: Help search engine crawlers to find out what pages are present and which have recently changed, and to crawl your site accordingly (This file is automatically generated by Odoo).
+ Sitemap.xml: Help search engine crawlers to find out what pages are present and which have recently changed, and to crawl your site accordingly. This file is automatically generated by Odoo.
</div>
<div class="mt4">
<button type="object" name="action_ping_sitemap" string="Submit sitemap to Google" class='btn-link' icon="fa-google"/>
diff --git a/addons/website/wizard/website_robots.xml b/addons/website/wizard/website_robots.xml
index 15198cb948b..dd0a9147459 100644
--- a/addons/website/wizard/website_robots.xml
+++ b/addons/website/wizard/website_robots.xml
@@ -9,7 +9,7 @@
<field name="content"/>
<small>
<a role="button" class="btn btn-link" target="_blank" href="https://www.google.com/webmasters/tools/robots-testing-tool">
- > Test your robots.txt with Google
+ Test your robots.txt with Google Search Console
</a>
<br/><br/>
Example of rule:<br/>
diff --git a/addons/website_form/__manifest__.py b/addons/website_form/__manifest__.py
index c052f3168ed..8030db83be7 100644
--- a/addons/website_form/__manifest__.py
+++ b/addons/website_form/__manifest__.py
@@ -12,7 +12,6 @@
'data/mail_mail_data.xml',
'views/assets.xml',
'views/ir_model_views.xml',
- 'views/res_config_view.xml',
'views/snippets.xml',
'views/website_form_templates.xml',
],
diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py
index 2e4d15dd3e2..d880009cf7d 100644
--- a/addons/website_form/controllers/main.py
+++ b/addons/website_form/controllers/main.py
@@ -147,9 +147,9 @@ class WebsiteForm(http.Controller):
elif field_name != 'context':
data['custom'] += u"%s : %s\n" % (field_name, field_value)
- # Add metadata if enabled
- environ = request.httprequest.headers.environ
- if(request.website.website_form_enable_metadata):
+ # Add metadata if enabled # ICP for retrocompatibility
+ if request.env['ir.config_parameter'].sudo().get_param('website_form_enable_metadata'):
+ environ = request.httprequest.headers.environ
data['meta'] += "%s : %s\n%s : %s\n%s : %s\n%s : %s\n" % (
"IP" , environ.get("REMOTE_ADDR"),
"USER_AGENT" , environ.get("HTTP_USER_AGENT"),
diff --git a/addons/website_form/models/models.py b/addons/website_form/models/models.py
index c3755143daa..fb4f73c39d3 100644
--- a/addons/website_form/models/models.py
+++ b/addons/website_form/models/models.py
@@ -8,19 +8,12 @@ from odoo.http import request
class website_form_config(models.Model):
_inherit = 'website'
- website_form_enable_metadata = fields.Boolean('Technical data on contact form', help="You can choose to log technical data like IP, User Agent ,...")
-
def _website_form_last_record(self):
if request and request.session.form_builder_model_model:
return request.env[request.session.form_builder_model_model].browse(request.session.form_builder_id)
return False
-class ResConfigSettings(models.TransientModel):
- _inherit = 'res.config.settings'
- website_form_enable_metadata = fields.Boolean(related="website_id.website_form_enable_metadata", readonly=False)
-
-
class website_form_model(models.Model):
_name = 'ir.model'
_description = 'Models'
diff --git a/addons/website_form/views/res_config_view.xml b/addons/website_form/views/res_config_view.xml
deleted file mode 100644
index 3998dadf564..00000000000
--- a/addons/website_form/views/res_config_view.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
- <record id="res_config_settings_view_form" model="ir.ui.view">
- <field name="model">res.config.settings</field>
- <field name="inherit_id" ref="website.res_config_settings_view_form"/>
- <field name="arch" type="xml">
- <xpath expr="//div[@id='social_default_image_setting']" position="before">
- <div class="col-12 col-lg-6 o_setting_box" groups="base.group_no_one" name="metadata_setting_container">
- <div class="o_setting_left_pane">
- <field name="website_form_enable_metadata"/>
- </div>
- <div class="o_setting_right_pane">
- <label for="website_form_enable_metadata"/>
- <span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
- <div class="text-muted">
- Track metadata (IP, User Agent, ...) on your Website Forms
- </div>
- </div>
- </div>
- </xpath>
- </field>
- </record>
-</odoo>