diff --git a/web_window_title/__init__.py b/web_window_title/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/web_window_title/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/web_window_title/__manifest__.py b/web_window_title/__manifest__.py new file mode 100644 index 0000000..4cc0d43 --- /dev/null +++ b/web_window_title/__manifest__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +{ + 'license': 'LGPL-3', + 'name': "Web Window Title", + 'summary': "The custom web window title", + 'author': "renjie ", + 'website': "https://renjie.me", + 'support': 'i@renjie.me', + 'category': 'Extra Tools', + 'version': '1.1', + 'depends': ['base_setup'], + 'demo': [ + 'data/demo.xml', + ], + 'data': [ + 'views/res_config.xml', + ], + 'images': [ + 'static/description/main_screenshot.png', + ], + 'assets': { + 'web.assets_backend': [ + 'web_window_title/static/src/js/web_window_title.js', + ], + }, + 'installable': True, + 'auto_install': False, + 'application': False, +} \ No newline at end of file diff --git a/web_window_title/data/demo.xml b/web_window_title/data/demo.xml new file mode 100644 index 0000000..937ce77 --- /dev/null +++ b/web_window_title/data/demo.xml @@ -0,0 +1,11 @@ + + + + + + web.base.title + Demo + + + + \ No newline at end of file diff --git a/web_window_title/models/__init__.py b/web_window_title/models/__init__.py new file mode 100644 index 0000000..b4db3f9 --- /dev/null +++ b/web_window_title/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import ir_ui_view +from . import res_config diff --git a/web_window_title/models/ir_ui_view.py b/web_window_title/models/ir_ui_view.py new file mode 100644 index 0000000..633dbc9 --- /dev/null +++ b/web_window_title/models/ir_ui_view.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +import logging + +from odoo import api, fields, models, _ + +_logger = logging.getLogger(__name__) + +class View(models.Model): + _inherit = 'ir.ui.view' + + @api.model + def _render_template(self, template, values=None): + if template in ['web.login', 'web.webclient_bootstrap']: + if not values: + values = {} + values["title"] = self.env['ir.config_parameter'].sudo().get_param("web.base.title", "") + return super(View, self)._render_template(template, values) diff --git a/web_window_title/models/res_config.py b/web_window_title/models/res_config.py new file mode 100644 index 0000000..dcacb5d --- /dev/null +++ b/web_window_title/models/res_config.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import logging + +from odoo import api, fields, models, _ + +_logger = logging.getLogger(__name__) + +CONFIG_PARAM_WEB_WINDOW_TITLE = "web.base.title" + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + web_window_title = fields.Char('Window Title') + + @api.model + def get_values(self): + res = super(ResConfigSettings, self).get_values() + ir_config = self.env['ir.config_parameter'].sudo() + web_window_title = ir_config.get_param(CONFIG_PARAM_WEB_WINDOW_TITLE, default='') + res.update( + web_window_title=web_window_title + ) + return res + + def set_values(self): + super(ResConfigSettings, self).set_values() + ir_config = self.env['ir.config_parameter'].sudo() + ir_config.set_param(CONFIG_PARAM_WEB_WINDOW_TITLE, self.web_window_title or "") diff --git a/web_window_title/static/description/icon.png b/web_window_title/static/description/icon.png new file mode 100644 index 0000000..66573ce Binary files /dev/null and b/web_window_title/static/description/icon.png differ diff --git a/web_window_title/static/description/index.html b/web_window_title/static/description/index.html new file mode 100644 index 0000000..8a767a0 --- /dev/null +++ b/web_window_title/static/description/index.html @@ -0,0 +1,33 @@ +
+
+
+

Web Window Title

+

The custom web window title

+
+
+
+ +
+
+
+
+
+
+
+

Odoo/OpenERP Full Stack Customization and Development

+ + +
+
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/web_window_title/static/description/main_screenshot.png b/web_window_title/static/description/main_screenshot.png new file mode 100644 index 0000000..fdca229 Binary files /dev/null and b/web_window_title/static/description/main_screenshot.png differ diff --git a/web_window_title/static/src/js/web_window_title.js b/web_window_title/static/src/js/web_window_title.js new file mode 100644 index 0000000..f6fd363 --- /dev/null +++ b/web_window_title/static/src/js/web_window_title.js @@ -0,0 +1,12 @@ +/** @odoo-module alias=web.window.title **/ + +import { WebClient } from "@web/webclient/webclient"; +import {patch} from "@web/core/utils/patch"; + +patch(WebClient.prototype, "Web Window Title", { + setup() { + const title = document.title; + this._super(); + this.title.setParts({ zopenerp: title }); + } +}); diff --git a/web_window_title/views/res_config.xml b/web_window_title/views/res_config.xml new file mode 100644 index 0000000..5a60970 --- /dev/null +++ b/web_window_title/views/res_config.xml @@ -0,0 +1,33 @@ + + + + + + res.config.settings.web.window.title + res.config.settings + + +
+

Window

+
+
+
+ Title +
+ The custom web window title +
+
+
+
+
+
+
+
+
+
+
+ +
+
\ No newline at end of file