commit 69eedcc142e07f6200f2d130c7ef588a4025c83d Author: Suherdy Yacob Date: Thu Jan 29 16:57:39 2026 +0700 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb0c1fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class + +# Odoo +.ipynb_checkpoints/ +odoo/ +.env + +# Editor +.vscode/ +.idea/ +*.swp diff --git a/README.md b/README.md new file mode 100644 index 0000000..f42adcf --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Custom Disable AI Icon + +This module allows administrators to hide the AI assistant icon in the systray (top right corner) for specific users. + +## Features +- adds a new security group "Hide AI Icon". +- Hides the AI icon in the web client for users belonging to this group. + +## Installation +1. Place the module in your Odoo `addons` path. +2. Update the app list. +3. Install the "Custom Disable AI Icon" module. + +## Configuration +To hide the AI icon for a user: +1. Go to **Settings > Users & Companies > Users**. +2. Select the user. +3. In the **Access Rights** tab, scroll to the **Administration** section (or check other sections depending on Odoo version layout). +4. Check the box **"Hide AI Icon"**. +5. Save the user record. +6. The user may need to refresh their browser for the change to take effect. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..ff7df27 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,16 @@ +{ + 'name': 'Custom Disable AI Icon', + 'version': '1.0', + 'category': 'Hidden', + 'summary': 'Hide AI Icon for specific users', + 'depends': ['ai', 'web'], + 'data': [ + 'security/security.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'custom_disable_ai/static/src/systray_patch.js', + ], + }, + 'license': 'LGPL-3', +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..9a5eb71 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import ir_http diff --git a/models/ir_http.py b/models/ir_http.py new file mode 100644 index 0000000..a370311 --- /dev/null +++ b/models/ir_http.py @@ -0,0 +1,9 @@ +from odoo import models + +class IrHttp(models.AbstractModel): + _inherit = 'ir.http' + + def session_info(self): + result = super().session_info() + result['is_ai_hidden'] = self.env.user.has_group('custom_disable_ai.group_hide_ai_icon') + return result diff --git a/security/security.xml b/security/security.xml new file mode 100644 index 0000000..12d7747 --- /dev/null +++ b/security/security.xml @@ -0,0 +1,15 @@ + + + + + AI Icon Visibility + + + + + Hide AI Icon + + + + + diff --git a/static/src/systray_patch.js b/static/src/systray_patch.js new file mode 100644 index 0000000..3b0bcd6 --- /dev/null +++ b/static/src/systray_patch.js @@ -0,0 +1,14 @@ +import { registry } from "@web/core/registry"; +import { session } from "@web/session"; + +const systrayRegistry = registry.category("systray"); + +const originalAIItem = systrayRegistry.get("ai.systray_action"); +if (originalAIItem) { + systrayRegistry.add("ai.systray_action", { + ...originalAIItem, + isDisplayed: (env) => { + return !session.is_ai_hidden; + } + }, { force: true }); +}