first commit
This commit is contained in:
commit
b601d5da59
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Python
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
__pycache__/
|
||||
|
||||
# Odoo
|
||||
*.pot
|
||||
*.po
|
||||
|
||||
# Editor
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
21
README.md
Normal file
21
README.md
Normal file
@ -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
|
||||
1
__init__.py
Normal file
1
__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import models
|
||||
21
__manifest__.py
Normal file
21
__manifest__.py
Normal file
@ -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',
|
||||
}
|
||||
1
models/__init__.py
Normal file
1
models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import res_users
|
||||
13
models/res_users.py
Normal file
13
models/res_users.py
Normal file
@ -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."
|
||||
)
|
||||
9
security/account_security.xml
Normal file
9
security/account_security.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="journal_comp_rule_allowed_journals" model="ir.rule">
|
||||
<field name="name">Journal Multi-Company with Allowed Journals</field>
|
||||
<field name="model_id" ref="account.model_account_journal"/>
|
||||
<field name="domain_force">[(1, '=', 1)] if not user.allowed_journal_ids else [('id', 'in', user.allowed_journal_ids.ids)]</field>
|
||||
<field name="global" eval="True"/>
|
||||
</record>
|
||||
</odoo>
|
||||
17
views/res_users_views.xml
Normal file
17
views/res_users_views.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_users_form_allowed_journals" model="ir.ui.view">
|
||||
<field name="name">res.users.form.allowed.journals</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Allowed Journals">
|
||||
<group>
|
||||
<field name="allowed_journal_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue
Block a user