Skip to content

Commit 05b8607

Browse files
committed
spp_branding_kit: refine controllers and hooks; correct JSON response; keep correct Odoo series; avoid disabling cache-clear cron; doc addon path fix; mark user field readonly; limit telemetry XHR interception
1 parent 02a4ed8 commit 05b8607

File tree

6 files changed

+28
-40
lines changed

6 files changed

+28
-40
lines changed

spp_branding_kit/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def post_init_hook(env):
2525
brand_promotion.active = False
2626
_logger.info("Disabled Odoo brand promotion message")
2727

28-
# Disable specific Odoo telemetry and update cron jobs by their external IDs
28+
# Disable specific Odoo update notification cron (if present)
2929
crons_to_disable = [
3030
"mail.ir_cron_module_update_notification", # Module update notification
31-
"base.ir_cron_res_partner_clear_caches", # Partner cache clearing (if telemetry related)
3231
]
3332

3433
for cron_xml_id in crons_to_disable:

spp_branding_kit/controllers/main.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
# ABOUTME: Main controller for OpenSPP Branding Kit
2-
# ABOUTME: Handles custom routes, branding overrides, and security enforcement
2+
# ABOUTME: Handles custom routes and branding-related endpoints
33

44
import json
55

6+
from werkzeug.wrappers import Response
7+
68
from odoo import http
79
from odoo.http import request
810

9-
from odoo.addons.portal.controllers.web import Home
10-
11-
12-
class OpenSPPHome(Home):
13-
"""Override Home controller to enforce branding and security settings"""
14-
15-
@http.route()
16-
def web_client(self, s_action=None, **kw):
17-
"""Override web client for branding"""
18-
return super().web_client(s_action, **kw)
19-
2011

2112
class OpenSPPBrandingController(http.Controller):
2213
"""Custom routes for OpenSPP branding"""
@@ -44,7 +35,8 @@ def version_info(self):
4435
system_name = config_parameter.get_param("openspp.system_name", "OpenSPP Platform")
4536
return {
4637
"server_version": system_name,
47-
"server_serie": "1.0",
38+
# Keep the server series aligned with the actual Odoo major version
39+
"server_serie": "17.0",
4840
"protocol_version": 1,
4941
}
5042

@@ -55,12 +47,16 @@ def publisher_warranty(self, **kwargs):
5547
telemetry_enabled = config_parameter.get_param("openspp.telemetry_enabled", "True") == "True"
5648

5749
if not telemetry_enabled:
58-
return json.dumps({"status": "disabled", "message": "Telemetry disabled"})
50+
payload = {"status": "disabled", "message": "Telemetry disabled"}
5951
else:
6052
# Redirect to OpenSPP telemetry endpoint
6153
telemetry_endpoint = config_parameter.get_param(
6254
"openspp.telemetry_endpoint", "https://telemetry.openspp.org"
6355
)
64-
return json.dumps(
65-
{"status": "redirected", "endpoint": telemetry_endpoint, "message": "Telemetry redirected to OpenSPP"}
66-
)
56+
payload = {
57+
"status": "redirected",
58+
"endpoint": telemetry_endpoint,
59+
"message": "Telemetry redirected to OpenSPP",
60+
}
61+
62+
return Response(json.dumps(payload), content_type="application/json")

spp_branding_kit/models/ir_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def session_info(self):
3333
}
3434
)
3535

36-
# Customize server version info
36+
# Customize server version info while keeping the correct Odoo series
3737
if "server_version_info" in result:
38-
result["server_version_info"] = ["OpenSPP", "1.0", "", "", ""]
38+
result["server_version_info"] = ["OpenSPP", "17.0", "", "", ""]
3939

4040
return result

spp_branding_kit/models/res_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ def _compute_odoo_account_url(self):
2222
user.odoo_account_url = False
2323

2424
odoo_account_url = fields.Char(
25-
compute="_compute_odoo_account_url", string="Account URL", help="OpenSPP Account Management"
25+
compute="_compute_odoo_account_url", string="Account URL", help="OpenSPP Account Management", readonly=True
2626
)

spp_branding_kit/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ <h3>Installation Steps</h3>
143143
<li>Clone the OCA server-brand repository:
144144
<div class="code">git clone --branch 17.0 https://github.com/OCA/server-brand.git</div>
145145
</li>
146-
<li>Add both module paths to your Odoo configuration:
147-
<div class="code">addons_path = /path/to/openspp_branding_kit,/path/to/server-brand,...</div>
146+
<li>Add both module paths to your Odoo configuration (directories containing your addons):
147+
<div class="code">addons_path = /path/to/custom-addons,/path/to/server-brand,/path/to/odoo/addons</div>
148148
</li>
149149
<li>Restart Odoo server and update the apps list</li>
150150
<li>Install the OpenSPP Branding Kit module from the Apps menu</li>
@@ -220,4 +220,4 @@ <h2>License</h2>
220220
</div>
221221
</div>
222222
</body>
223-
</html>
223+
</html>

spp_branding_kit/static/src/js/telemetry_manager.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const telemetryEnabled = session.openspp_telemetry_enabled !== false;
77
const telemetryEndpoint = session.openspp_telemetry_endpoint || "https://telemetry.openspp.org";
88

99
// Log telemetry configuration for debugging
10-
if (!telemetryEnabled) {
11-
console.log("OpenSPP: Telemetry is disabled");
12-
} else {
10+
if (telemetryEnabled) {
1311
console.log("OpenSPP: Telemetry endpoint:", telemetryEndpoint);
12+
} else {
13+
console.log("OpenSPP: Telemetry is disabled");
1414
}
1515

1616
// In Odoo 17, telemetry blocking is better handled at the controller level
@@ -28,24 +28,17 @@ XMLHttpRequest.prototype.open = function (method, url, ...args) {
2828
if (shouldBlock) {
2929
if (!telemetryEnabled) {
3030
console.log("OpenSPP: Blocked telemetry call to", url);
31-
// Return a dummy request that does nothing
31+
// Replace send/abort with harmless stubs
3232
this.send = function () {
33-
// Intentionally empty to block telemetry
33+
return false;
3434
};
3535
this.abort = function () {
36-
// Intentionally empty to block telemetry
36+
return null;
3737
};
3838
return;
3939
}
40-
console.log("OpenSPP: Would redirect telemetry from", url, "to", telemetryEndpoint);
41-
// For now, block the call as redirection requires backend implementation
42-
this.send = function () {
43-
// Intentionally empty to block telemetry
44-
};
45-
this.abort = function () {
46-
// Intentionally empty to block telemetry
47-
};
48-
return;
40+
// When telemetry is enabled, do not intercept; server handles /publisher-warranty
41+
// Optionally, you could redirect here, but we keep the default behavior
4942
}
5043

5144
return originalOpen.call(this, method, url, ...args);

0 commit comments

Comments
 (0)