Skip to content

Commit 02a4ed8

Browse files
committed
spp_branding_kit: drop server-side Apps filtering; UI-only default to OpenSPP Apps, remove apps_filter asset; hide obsolete settings; fix favicon path; keep ir.module.module ORM unchanged
1 parent ebfc88f commit 02a4ed8

File tree

8 files changed

+24
-166
lines changed

8 files changed

+24
-166
lines changed

spp_branding_kit/__init__.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,7 @@ def post_init_hook(env):
1515
"""
1616
_logger.info("OpenSPP Branding Kit: Running post-installation setup...")
1717

18-
# Set default configuration parameters
19-
try:
20-
IrConfigParam = env["ir.config_parameter"].sudo()
21-
22-
# Set hide paid apps to True by default (if not already set)
23-
if not IrConfigParam.get_param("openspp.hide_paid_apps"):
24-
IrConfigParam.set_param("openspp.hide_paid_apps", "True")
25-
_logger.info("Set hide paid apps to True by default")
26-
27-
# Set default app filter to 'apps_only' (if not already set)
28-
if not IrConfigParam.get_param("openspp.default_app_filter"):
29-
IrConfigParam.set_param("openspp.default_app_filter", "apps_only")
30-
_logger.info("Set default app filter to 'apps_only'")
31-
32-
except Exception as e:
33-
_logger.warning(f"Error setting default parameters: {e}")
18+
# No default parameters for app filtering; UI handles Apps filters now
3419

3520
# Disable Odoo branding elements
3621
try:

spp_branding_kit/__manifest__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"spp_branding_kit/static/src/js/webclient.js",
5353
"spp_branding_kit/static/src/js/user_menu.js",
5454
"spp_branding_kit/static/src/js/telemetry_manager.js",
55-
"spp_branding_kit/static/src/js/apps_filter.js",
5655
],
5756
"web.assets_frontend": [
5857
"spp_branding_kit/static/src/css/login_branding.css",

spp_branding_kit/data/ir_config_parameter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<!-- Custom Favicon Path -->
8686
<record id="param_favicon_path" model="ir.config_parameter">
8787
<field name="key">openspp.favicon_path</field>
88-
<field name="value">/openspp_branding_kit/static/description/icon.png</field>
88+
<field name="value">/spp_branding_kit/static/description/icon.png</field>
8989
</record>
9090

9191
<!-- Theme Configuration -->
Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# ABOUTME: Override ir.module.module to filter paid apps from the app list
2-
# ABOUTME: Provides option to hide paid Odoo apps based on configuration
1+
# ABOUTME: Minimal extension of ir.module.module for helper counts only
2+
# ABOUTME: Server-side filtering is intentionally avoided; UI handles filters
33

44
from odoo import api, models
55

@@ -13,64 +13,5 @@ def get_paid_apps_count(self):
1313
paid_apps = self.search(["|", ("license", "=like", "OEEL%"), ("license", "=like", "OPL%")])
1414
return len(paid_apps)
1515

16-
@api.model
17-
def _get_paid_app_filter(self):
18-
"""Helper method to get the domain filter for paid apps"""
19-
# This filter excludes modules with OEEL or OPL licenses
20-
# The correct way to exclude paid apps while including modules with no license
21-
return ["&", ("license", "not like", "OEEL%"), ("license", "not like", "OPL%")]
22-
23-
@api.model
24-
def _apply_paid_app_filter(self, domain):
25-
"""Helper method to apply paid app filter to a domain"""
26-
hide_paid_apps = self.env["ir.config_parameter"].sudo().get_param("openspp.hide_paid_apps", "False")
27-
hide_paid_apps = hide_paid_apps == "True"
28-
29-
if hide_paid_apps and self.env.context.get("apps_menu", False):
30-
paid_app_filter = self._get_paid_app_filter()
31-
if domain:
32-
return ["&"] + domain + paid_app_filter
33-
else:
34-
return paid_app_filter
35-
return domain
36-
37-
@api.model
38-
def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=None):
39-
"""Override search to filter paid apps based on configuration"""
40-
# Apply paid app filter if needed
41-
domain = self._apply_paid_app_filter(domain)
42-
43-
# Add context to inform views about the setting
44-
hide_paid_apps = self.env["ir.config_parameter"].sudo().get_param("openspp.hide_paid_apps", "False")
45-
if hide_paid_apps == "True":
46-
self = self.with_context(hide_paid_apps_enabled=True)
47-
48-
return super()._search(domain, offset=offset, limit=limit, order=order, access_rights_uid=access_rights_uid)
49-
50-
@api.model
51-
def search_fetch(self, domain, field_names, offset=0, limit=None, order=None):
52-
"""Override search_fetch to filter paid apps based on configuration"""
53-
# Apply paid app filter if needed
54-
domain = self._apply_paid_app_filter(domain)
55-
56-
# Add context to inform views about the setting
57-
hide_paid_apps = self.env["ir.config_parameter"].sudo().get_param("openspp.hide_paid_apps", "False")
58-
if hide_paid_apps == "True":
59-
self = self.with_context(hide_paid_apps_enabled=True)
60-
61-
return super().search_fetch(domain, field_names, offset=offset, limit=limit, order=order)
62-
63-
@api.model
64-
def web_search_read(self, domain=None, specification=None, offset=0, limit=None, order=None, count_limit=None):
65-
"""Override web_search_read to filter paid apps in the UI"""
66-
# Apply paid app filter if needed
67-
domain = self._apply_paid_app_filter(domain)
68-
69-
# Add context to inform views about the setting
70-
hide_paid_apps = self.env["ir.config_parameter"].sudo().get_param("openspp.hide_paid_apps", "False")
71-
if hide_paid_apps == "True":
72-
self = self.with_context(hide_paid_apps_enabled=True)
73-
74-
return super().web_search_read(
75-
domain=domain, specification=specification, offset=offset, limit=limit, order=order, count_limit=count_limit
76-
)
16+
# No overrides of install/upgrade/uninstall buttons are needed once
17+
# _search is left untouched; UI filtering is handled via web_* APIs.

spp_branding_kit/static/src/js/apps_filter.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

spp_branding_kit/tests/test_hide_paid_apps.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def test_paid_apps_hidden_when_enabled(self):
6565
"""Test that paid apps are hidden when setting is enabled"""
6666
# Enable hiding paid apps
6767
self.IrConfigParam.set_param("openspp.hide_paid_apps", "True")
68-
69-
# Search for modules in Apps context
70-
modules = self.Module.with_context(apps_menu=True).search([])
71-
72-
# Check that our test paid modules are NOT visible, but free module is
73-
self.assertNotIn(self.paid_module_oeel, modules, "OEEL test module should be hidden when setting is enabled")
74-
self.assertNotIn(self.paid_module_opl, modules, "OPL test module should be hidden when setting is enabled")
75-
self.assertIn(self.free_module, modules, "Free module should still be visible")
68+
# Use web API read for Apps UI (filtered)
69+
result = self.Module.with_context(apps_menu=True).web_search_read(
70+
domain=[], specification={"name": {}, "license": {}}
71+
)
72+
names = {r["name"] for r in result["records"]}
73+
self.assertNotIn(self.paid_module_oeel.name, names, "OEEL test module should be hidden when setting is enabled")
74+
self.assertNotIn(self.paid_module_opl.name, names, "OPL test module should be hidden when setting is enabled")
75+
self.assertIn(self.free_module.name, names, "Free module should still be visible")
7676

7777
def test_paid_apps_visible_outside_apps_menu(self):
7878
"""Test that paid apps remain visible in module management views"""
@@ -87,19 +87,12 @@ def test_paid_apps_visible_outside_apps_menu(self):
8787
self.assertIn(self.paid_module_opl, modules, "OPL test module should be visible outside apps menu")
8888
self.assertIn(self.free_module, modules, "Free module should be visible outside apps menu")
8989

90-
def test_search_methods_respect_setting(self):
90+
def test_ui_search_methods_respect_setting(self):
9191
"""Test that all search methods respect the hide paid apps setting"""
9292
# Enable hiding paid apps
9393
self.IrConfigParam.set_param("openspp.hide_paid_apps", "True")
9494

95-
# Test _search method
9695
domain = [("application", "=", True)]
97-
module_ids = self.Module.with_context(apps_menu=True)._search(domain)
98-
99-
# Our test paid modules should not be in results
100-
self.assertNotIn(self.paid_module_oeel.id, module_ids, "_search should filter OEEL apps")
101-
self.assertNotIn(self.paid_module_opl.id, module_ids, "_search should filter OPL apps")
102-
self.assertIn(self.free_module.id, module_ids, "_search should not filter free apps")
10396

10497
# Test search_fetch method
10598
modules = self.Module.with_context(apps_menu=True).search_fetch(domain, ["name", "license"])
@@ -141,7 +134,7 @@ def test_edge_cases_with_none_license(self):
141134
# Module with no license should be visible
142135
self.assertIn(no_license_module, modules, "Modules with no license should be visible")
143136

144-
def test_paid_license_variations(self):
137+
def test_paid_license_variations_filtered_in_ui(self):
145138
"""Test that different variations of paid licenses are filtered"""
146139
# Create modules with various paid license formats
147140
oeel_variations = [
@@ -173,9 +166,10 @@ def test_paid_license_variations(self):
173166
# Enable hiding paid apps
174167
self.IrConfigParam.set_param("openspp.hide_paid_apps", "True")
175168

176-
# Search for modules in Apps context
177-
modules = self.Module.with_context(apps_menu=True).search([])
178-
179-
# All paid license variations should be hidden
169+
# UI web read should filter paid license variants
170+
result = self.Module.with_context(apps_menu=True).web_search_read(
171+
domain=[], specification={"name": {}, "license": {}}
172+
)
173+
names = {r["name"] for r in result["records"]}
180174
for module in oeel_variations + opl_variations:
181-
self.assertNotIn(module, modules, f"Module with license {module.license} should be hidden")
175+
self.assertNotIn(module.name, names, f"Module with license {module.license} should be hidden")

spp_branding_kit/views/ir_module_module_views.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@
8282

8383
<!-- Override Apps menu action to include context and default filter -->
8484
<record id="base.open_module_tree" model="ir.actions.act_window">
85-
<field name="context" eval="{'search_default_app': 1, 'apps_menu': True}" />
85+
<field name="context" eval="{'search_default_openspp_apps': 1}" />
8686
</record>
8787

8888
<!-- Create action for OpenSPP Apps specifically -->
8989
<record id="action_openspp_apps" model="ir.actions.act_window">
9090
<field name="name">OpenSPP Apps</field>
9191
<field name="res_model">ir.module.module</field>
9292
<field name="view_mode">kanban,tree,form</field>
93-
<field name="context">{'search_default_openspp_apps': 1, 'apps_menu': True}</field>
93+
<field name="context">{'search_default_openspp_apps': 1}</field>
9494
<field name="search_view_id" ref="base.view_module_filter" />
9595
<field name="help" type="html">
9696
<p class="o_view_nocontent_smiling_face">

spp_branding_kit/views/res_config_settings_views.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919
<setting help="Customize interface for OpenSPP-specific workflows">
2020
<field name="openspp_hide_odoo_referral" />
2121
</setting>
22-
<setting
23-
help="Hide paid Odoo apps (Enterprise and OPL licensed modules) from the Apps list"
24-
>
25-
<field name="openspp_hide_paid_apps" />
26-
</setting>
27-
<setting help="Choose which modules to show by default in the Apps menu">
28-
<field name="openspp_default_app_filter" widget="radio" />
29-
</setting>
3022
</block>
3123

3224
<block title="Help &amp; Support" name="openspp_links_block">

0 commit comments

Comments
 (0)