summaryrefslogtreecommitdiff
path: root/addons/website/wizard
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website/wizard
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website/wizard')
-rw-r--r--addons/website/wizard/__init__.py5
-rw-r--r--addons/website/wizard/base_language_install.py35
-rw-r--r--addons/website/wizard/base_language_install_views.xml15
-rw-r--r--addons/website/wizard/website_robots.py14
-rw-r--r--addons/website/wizard/website_robots.xml27
5 files changed, 96 insertions, 0 deletions
diff --git a/addons/website/wizard/__init__.py b/addons/website/wizard/__init__.py
new file mode 100644
index 00000000..48b16df8
--- /dev/null
+++ b/addons/website/wizard/__init__.py
@@ -0,0 +1,5 @@
+# -*- encoding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import base_language_install
+from . import website_robots
diff --git a/addons/website/wizard/base_language_install.py b/addons/website/wizard/base_language_install.py
new file mode 100644
index 00000000..b3c6225f
--- /dev/null
+++ b/addons/website/wizard/base_language_install.py
@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class BaseLanguageInstall(models.TransientModel):
+
+ _inherit = "base.language.install"
+
+ website_ids = fields.Many2many('website', string='Websites to translate')
+
+ @api.model
+ def default_get(self, fields):
+ defaults = super(BaseLanguageInstall, self).default_get(fields)
+ website_id = self._context.get('params', {}).get('website_id')
+ if website_id:
+ if 'website_ids' not in defaults:
+ defaults['website_ids'] = []
+ defaults['website_ids'].append(website_id)
+ return defaults
+
+ def lang_install(self):
+ action = super(BaseLanguageInstall, self).lang_install()
+ lang = self.env['res.lang']._lang_get(self.lang)
+ if self.website_ids and lang:
+ self.website_ids.write({'language_ids': [(4, lang.id)]})
+ params = self._context.get('params', {})
+ if 'url_return' in params:
+ return {
+ 'url': params['url_return'].replace('[lang]', self.lang),
+ 'type': 'ir.actions.act_url',
+ 'target': 'self'
+ }
+ return action
diff --git a/addons/website/wizard/base_language_install_views.xml b/addons/website/wizard/base_language_install_views.xml
new file mode 100644
index 00000000..df3062d2
--- /dev/null
+++ b/addons/website/wizard/base_language_install_views.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+
+ <record id="view_base_language_install" model="ir.ui.view">
+ <field name="name">view_base_language_install.inherit</field>
+ <field name="model">base.language.install</field>
+ <field name="inherit_id" ref="base.view_base_language_install"/>
+ <field name="arch" type="xml">
+ <group states="init" position="inside">
+ <field name="website_ids" widget="many2many_checkboxes" groups="website.group_multi_website"/>
+ </group>
+ </field>
+ </record>
+
+</odoo>
diff --git a/addons/website/wizard/website_robots.py b/addons/website/wizard/website_robots.py
new file mode 100644
index 00000000..1d68aa4f
--- /dev/null
+++ b/addons/website/wizard/website_robots.py
@@ -0,0 +1,14 @@
+# -*- encoding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from odoo import api, fields, models
+
+
+class WebsiteRobots(models.TransientModel):
+ _name = "website.robots"
+ _description = "Robots.txt Editor"
+
+ content = fields.Text(default=lambda s: s.env['website'].get_current_website().robots_txt)
+
+ def action_save(self):
+ self.env['website'].get_current_website().robots_txt = self.content
+ return {'type': 'ir.actions.act_window_close'}
diff --git a/addons/website/wizard/website_robots.xml b/addons/website/wizard/website_robots.xml
new file mode 100644
index 00000000..dd0a9147
--- /dev/null
+++ b/addons/website/wizard/website_robots.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+
+ <record id="view_edit_robots" model="ir.ui.view">
+ <field name="name">Edit Robots.txt</field>
+ <field name="model">website.robots</field>
+ <field name="arch" type="xml">
+ <form>
+ <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 Search Console
+ </a>
+ <br/><br/>
+ Example of rule:<br/>
+ <code class='ml-4'>Disallow: /web/login</code><br/>
+ <code class='ml-4'>Allow: *</code>
+ </small>
+ <footer>
+ <button string="Save" name="action_save" type="object" class="oe_highlight"/>
+ <button string="Cancel" class="btn btn-default" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+</odoo>