add web_window_title

This commit is contained in:
santi 2025-08-11 09:17:04 +00:00
parent c17ceb75a3
commit 190d1f09c2
11 changed files with 172 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
{
'license': 'LGPL-3',
'name': "Web Window Title",
'summary': "The custom web window title",
'author': "renjie <i@renjie.me>",
'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,
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="config_parameter_web_base_title_demo" model="ir.config_parameter">
<field name="key">web.base.title</field>
<field name="value">Demo</field>
</record>
</data>
</openerp>

View file

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import ir_ui_view
from . import res_config

View file

@ -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)

View file

@ -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 "")

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

View file

@ -0,0 +1,33 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Web Window Title</h2>
<h3 class="oe_slogan">The custom web window title</h3>
</div>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot" style="max-height:none">
<img src="main_screenshot.png"/>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span6">
<h3 class="oe_mt48 oe_slogan">Odoo/OpenERP Full Stack Customization and Development</h3>
<div class="oe_mt32 oe_mb32 text-center">
<a class="fa fa-eye" href="https://apps.odoo.com/apps/modules/browse?author=renjie%20%3Ci@renjie.me%3E" title="Works" target="_blank">Other Apps</a>
</div>
<div class="text-center">
<a class="fa fa-envelope" href="mailto:i@renjie.me" title="Support">i@renjie.me</a>
</div>
</div>
<div class="oe_span4">
<div class="oe_demo oe_picture oe_screenshot">
<a href="https://renjie.me" target="_blank">
<img src="icon.png" title="Renjie Technology">
</a>
</div>
</div>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View file

@ -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 });
}
});

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.web.window.title</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div id="languages" position="before">
<h2>Window</h2>
<div class="row mt16 o_settings_container" name="window">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label">Title</span>
<div class="text-muted">
The custom web window title
</div>
<div class="content-group">
<div class="mt16 row">
<label for="web_window_title" string="Title" class="col-3 col-lg-3 o_light_label"/>
<field name="web_window_title" class="oe_inline"/>
</div>
</div>
</div>
</div>
</div>
</div>
</field>
</record>
</data>
</odoo>