This commit is contained in:
李鹏宇
2026-06-04 14:24:28 +08:00
parent 91dceac262
commit cd653ce24c
774 changed files with 125051 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
from . import models
from odoo.addons.base.models.assetsbundle import JavascriptAsset
from odoo.tools import transpile_javascript
import re
import odoo
from .models.home import base_sorturl
from odoo.modules.registry import Registry
from odoo.http import ROUTING_KEYS
from odoo.tools.misc import submap
import werkzeug.utils
import werkzeug.routing
import werkzeug.exceptions
import werkzeug
from odoo.modules.registry import Registry
import threading
from odoo import tools
from odoo.addons.base.models.ir_http import _logger, FasterRule, IrHttp
import odoo
from odoo import http
def _uninstall_cleanup(env):
@property
def content(self):
if self.name == "/web/static/src/core/browser/router.js":
pass
content = super(JavascriptAsset, self).content
if self.is_transpiled:
if not self._converted_content:
self._converted_content = transpile_javascript(
self.url, content)
return self._converted_content
return content
JavascriptAsset.content = content
def url_init(self, httprequest):
self.httprequest = httprequest
self.future_response = http.FutureResponse()
self.dispatcher = http._dispatchers['http'](self)
self.geoip = http.GeoIP(httprequest.remote_addr)
self.registry = None
self.env = None
http.Request.__init__ = url_init
@tools.ormcache('key', cache='routing')
def routing_map(self, key=None):
_logger.info("Generating routing map for key %s", str(key))
registry = Registry(threading.current_thread().dbname)
installed = registry._init_modules.union(odoo.conf.server_wide_modules)
mods = sorted(installed)
routing_map = werkzeug.routing.Map(
strict_slashes=False, converters=self._get_converters())
for url, endpoint in self._generate_routing_rules(mods, converters=self._get_converters()):
routing = submap(endpoint.routing, ROUTING_KEYS)
if routing['methods'] is not None and 'OPTIONS' not in routing['methods']:
routing['methods'] = routing['methods'] + ['OPTIONS']
rule = FasterRule(url, endpoint=endpoint, **routing)
rule.merge_slashes = False
routing_map.add(rule)
return routing_map
IrHttp.routing_map = routing_map
env['ir.http'].env.registry.clear_cache("routing")
env['ir.attachment'].regenerate_assets_bundles()
+28
View File
@@ -0,0 +1,28 @@
# Copyright 2018 Simone Orsi - Camptocamp SA
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
{
"name": "Url odoo18 Replace",
'version': '1.0.3',
"author": "1311793927@qq.com",
'support': '1311793927qq.com',
"summary": "URL Replace link",
"description":"Odoo18 Replace odoo in hyperlink",
"category": "Extra Tools",
"license": "LGPL-3",
'images': ['static/description/main_banner.png'],
"depends": ["web",'base'],
"application": False,
"installable": True,
"data": [
'data/data.xml',
'views/ir_config_parameter_views.xml'
],
"assets": {
"web.assets_backend": [
"web_replace_url/static/src/**/*",
],
},
"installable": True,
# 'uninstall_hook': '_uninstall_cleanup',
# 'post_init_hook': '_setup_module',
}
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="rec_config_parameter_web_basesorturl" model="ir.config_parameter">
<field name="key">web.base.sorturl</field>
<field name="value">china</field>
</record>
</data>
</odoo>
+1
View File
@@ -0,0 +1 @@
from . import home
+95
View File
@@ -0,0 +1,95 @@
import json
import logging
import psycopg2
import threading
from odoo import tools
from odoo.addons.base.models.ir_http import _logger, FasterRule, IrHttp
import odoo
from odoo import http
from odoo.http import ROUTING_KEYS
from odoo.tools.misc import submap
import odoo.exceptions
import odoo.modules.registry
from odoo import http
from odoo.exceptions import AccessError
from odoo.http import request
from odoo.service import security
from odoo.tools.translate import _
from odoo.modules.registry import Registry
from odoo import api, fields, models, _
from odoo.tools import transpile_javascript
from odoo.addons.base.models import ir_config_parameter
from odoo.addons.base.models.assetsbundle import JavascriptAsset
import werkzeug.utils
import werkzeug.routing
import werkzeug.exceptions
import werkzeug
import re
base_sorturl=['']
class IrConfigParameter(models.Model):
_inherit = "ir.config_parameter"
def write(self, vals):
data = super(IrConfigParameter, self).write(vals)
if data and self.key == 'web.base.sorturl' :
self.env['ir.http'].env.registry.clear_cache("routing")
self.env['ir.attachment'].regenerate_assets_bundles()
return {'type': 'ir.actions.client', 'tag': 'soft_reload'}
@property
def content(self):
content = super(JavascriptAsset, self).content
if self.name == "/web/static/src/core/browser/router.js":
content = re.sub(r'(?<!@)odoo', base_sorturl[0], content)
if self.name == "/web/static/src/webclient/navbar/navbar.js":
content = re.sub(r'(?<!@)odoo', base_sorturl[0], content)
if self.is_transpiled:
if not self._converted_content:
self._converted_content = transpile_javascript(
self.url, content)
return self._converted_content
return content
JavascriptAsset.content = content
def url_init(self, httprequest):
if "odoo" in httprequest.path and "/web/static" not in httprequest.path:
httprequest.path = httprequest.path.replace(
"odoo", base_sorturl[0])
self.httprequest = httprequest
self.future_response = http.FutureResponse()
self.dispatcher = http._dispatchers['http'](self)
self.geoip = http.GeoIP(httprequest.remote_addr)
self.registry = None
self.env = None
http.Request.__init__ = url_init
@tools.ormcache('key', cache='routing')
def routing_map(self, key=None):
config_parameter = self.env['ir.config_parameter']
base_sorturl[0] = config_parameter.sudo(
).get_param("web.base.sorturl", "")
_logger.info("Generating routing map for key %s", str(key))
registry = Registry(threading.current_thread().dbname)
installed = registry._init_modules.union(
odoo.conf.server_wide_modules)
mods = sorted(installed)
routing_map = werkzeug.routing.Map(
strict_slashes=False, converters=self._get_converters())
for url, endpoint in self._generate_routing_rules(mods, converters=self._get_converters()):
if 'odoo' in url:
url = url.replace('odoo', base_sorturl[0])
routing = submap(endpoint.routing, ROUTING_KEYS)
if routing['methods'] is not None and 'OPTIONS' not in routing['methods']:
routing['methods'] = routing['methods'] + ['OPTIONS']
rule = FasterRule(url, endpoint=endpoint, **routing)
rule.merge_slashes = False
routing_map.add(rule)
return routing_map
IrHttp.routing_map = routing_map
+28
View File
@@ -0,0 +1,28 @@
# Copyright 2018 Simone Orsi - Camptocamp SA
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
{
"name": "Url odoo18 Replace",
'version': '1.0.3',
"author": "1311793927@qq.com",
'support': '1311793927qq.com',
"summary": "URL Replace link",
"description":"Odoo18 Replace odoo in hyperlink",
"category": "Extra Tools",
"license": "LGPL-3",
'images': ['static/description/main_banner.png'],
"depends": ["web",'base'],
"application": False,
"installable": True,
"data": [
'data/data.xml',
'views/ir_config_parameter_views.xml'
],
"assets": {
"web.assets_backend": [
"web_replace_url/static/src/**/*",
],
},
"installable": True,
'uninstall_hook': '_uninstall_cleanup',
'post_init_hook': '_setup_module',
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@@ -0,0 +1,12 @@
<section class="oe_container oe_slogan">
<H3>
The bug has been resolved
</H3>
<span style="color: red;">After uninstalling the module, please clear the browser cache</span>
<br/>
<br/>
<img src="1.png" style="width:950px">
</section>
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@@ -0,0 +1,23 @@
import { rpc } from "@web/core/network/rpc";
import { registry } from "@web/core/registry";
import { FormController } from "@web/views/form/form_controller";
import { formView } from "@web/views/form/form_view";
import { browser } from '@web/core/browser/browser';
import { redirect } from "@web/core/utils/urls";
const defaulRegistry= registry.category("default")
export class ReloadFormController extends FormController {
async save({ closable, ...otherParams }) {
const saved = await super.save(otherParams);
debugger
if ( saved && this.model.root._values.key=='web.base.sorturl'){
redirect("/?debug=assets")
}else{
return saved;
}
}}
export const ReloadFormView = {
...formView,
Controller: ReloadFormController,
};
registry.category("views").add("web_url_view_ir_config_inherit_form", ReloadFormView);
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="view_ir_config_inherit_form">
<field name="name">base.view_ir_config_inherit_form</field>
<field name="model">ir.config_parameter</field>
<field name="inherit_id" ref="base.view_ir_config_form"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="js_class">web_url_view_ir_config_inherit_form</attribute>
</xpath>
</field>
</record>
</odoo>