commit b601d5da59a35c9f04b8e3ee76e64fd2e443111c Author: Suherdy Yacob Date: Fri Jan 23 16:05:50 2026 +0700 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e8cc803 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# Python +*.py[cod] +*$py.class +__pycache__/ + +# Odoo +*.pot +*.po + +# Editor +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..c54fb8e --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Account Allowed Journal + +## Summary +This module allows restricting users to specific journals in Odoo's Accounting application. + +## Features +- adds a new field "Allowed Journals" to the User form view. +- **Access Control:** + - If "Allowed Journals" is **empty**, the user has access to **ALL** journals (standard behavior). + - If "Allowed Journals" is **populated**, the user can **ONLY** access the selected journals. +- Implements a global Record Rule to enforce this restriction across the system (Views, Search, Create, Write). + +## Configuration +1. Go to **Settings** > **Users & Companies** > **Users**. +2. Open the user you want to restrict. +3. Go to the **Allowed Journals** tab. +4. Add the journals the user is allowed to access. +5. Save. + +## License +LGPL-3 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..56ef1af --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,21 @@ +{ + 'name': 'Account Allowed Journal', + 'version': '17.0.1.0.0', + 'category': 'Accounting', + 'summary': 'Restrict user access to specific journals', + 'description': """ + This module allows restricting users to see and use only specific journals. + - Adds "Allowed Journals" field in User form. + - If "Allowed Journals" is set, the user can only access those journals. + - If "Allowed Journals" is empty, the user can access all journals. + """, + 'author': 'Antigravity', + 'depends': ['base', 'account'], + 'data': [ + 'security/account_security.xml', + 'views/res_users_views.xml', + ], + 'installable': True, + 'application': False, + 'license': 'LGPL-3', +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..8835165 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import res_users diff --git a/models/res_users.py b/models/res_users.py new file mode 100644 index 0000000..ecf5a32 --- /dev/null +++ b/models/res_users.py @@ -0,0 +1,13 @@ +from odoo import models, fields + +class ResUsers(models.Model): + _inherit = 'res.users' + + allowed_journal_ids = fields.Many2many( + 'account.journal', + 'res_users_account_journal_rel', + 'user_id', + 'journal_id', + string='Allowed Journals', + help="Allowed journals for this user. If empty, all journals are allowed." + ) diff --git a/security/account_security.xml b/security/account_security.xml new file mode 100644 index 0000000..fb85d14 --- /dev/null +++ b/security/account_security.xml @@ -0,0 +1,9 @@ + + + + Journal Multi-Company with Allowed Journals + + [(1, '=', 1)] if not user.allowed_journal_ids else [('id', 'in', user.allowed_journal_ids.ids)] + + + diff --git a/views/res_users_views.xml b/views/res_users_views.xml new file mode 100644 index 0000000..5d2f8a8 --- /dev/null +++ b/views/res_users_views.xml @@ -0,0 +1,17 @@ + + + + res.users.form.allowed.journals + res.users + + + + + + + + + + + +