diff --git a/college/__manifest__.py b/college/__manifest__.py index 5935a16..1195b10 100644 --- a/college/__manifest__.py +++ b/college/__manifest__.py @@ -1,6 +1,6 @@ { 'name': '教育', - 'version': '18.0.3.0.5', + 'version': '18.0.3.0.7', 'summary': 'Odoo 18 教学管理平台 — 师生管理 + 课程管理 + 作业/进展(老师·学生双角色)', 'description': """ Odoo 18 教学管理平台(面向老师与学生,双角色权限) @@ -60,6 +60,7 @@ 'college/static/src/scss/college_theme.scss', 'college/static/src/js/hide_company_menu.js', 'college/static/src/js/hide_user_menu_items.js', + 'college/static/src/js/hide_activity_menu.js', 'college/static/src/js/portal_indicator.js', 'college/static/src/xml/portal_indicator.xml', ], diff --git a/college/data/shixun_module_data.xml b/college/data/shixun_module_data.xml index e5959a4..0e135ce 100644 --- a/college/data/shixun_module_data.xml +++ b/college/data/shixun_module_data.xml @@ -23,7 +23,9 @@ 23=Fleet(车辆) 如需保留/恢复某类目,从下面列表中删除对应 id 即可(注意总数会变化)。 --> [('application', '=', True), ('category_id', 'not in', [13, 54, 71, 15, 94, 6, 10, 11, 20, 33, 55, 37, 59, 21, 89, 90, 92, 103, 28, 32, 88, 23])] - {} + + {'shixun_hide_empty_categories': True} 50 diff --git a/college/models/ir_module_module_info.py b/college/models/ir_module_module_info.py index da35cdc..3d963d1 100644 --- a/college/models/ir_module_module_info.py +++ b/college/models/ir_module_module_info.py @@ -48,6 +48,21 @@ class IrModuleModule(models.Model): help='在「模块信息 / 知识点」页展示的核心概念与使用要点(由 college 维护)', ) + @api.model + def search_panel_select_range(self, field_name, **kwargs): + """搜索面板类别列:按 context 开关过滤掉计数为 0 的顶层类别。 + + 背景:base 对 ir.module.module 的 search_panel_select_range 做了重写 + (ir_module.py),只要顶层类别的子树里存在任何模块就会返回该类别, + 即使它名下没有一条记录匹配当前搜索域(计数为 0、界面上不显示数字)。 + 「实训模块」动作通过 context 开关 shixun_hide_empty_categories 启用本过滤, + 不影响原生「应用」页面;hierarchize/expand 等视图属性在该重写分支中不生效。 + """ + res = super().search_panel_select_range(field_name, **kwargs) + if field_name == 'category_id' and self.env.context.get('shixun_hide_empty_categories'): + res['values'] = [v for v in res.get('values', []) if v.get('__count')] + return res + @api.model def populate_module_info(self): """为 school 自建模块写入「功能亮点 / 模块介绍」文案。 diff --git a/college/static/src/js/hide_activity_menu.js b/college/static/src/js/hide_activity_menu.js new file mode 100644 index 0000000..01d4939 --- /dev/null +++ b/college/static/src/js/hide_activity_menu.js @@ -0,0 +1,18 @@ +/** + * 隐藏导航栏右侧的「活动」图标(日历+时钟那个,点击弹出"我的活动"下拉) + * + * 原理:导航栏右侧的系统托盘 (systray) 是一个组件注册表, + * mail 模块在加载时把活动菜单注册了进去(见 + * odoo18/addons/mail/static/src/core/web/activity_menu.js 最后一行 + * registry.category("systray").add("mail.activity_menu", ...))。 + * 这里在资源包加载阶段把它从注册表里摘掉,导航栏就不会渲染它。 + * + * 如需恢复:删除本文件并把 __manifest__.py assets 里对应的一行去掉即可。 + * + * 注意:本文件改动需要「升级模块」才会生效(-d <库名> -u college), + * 并强刷浏览器 (Ctrl+Shift+R)。 + */ +/** @odoo-module **/ +import { registry } from "@web/core/registry"; + +registry.category("systray").remove("mail.activity_menu");