-
-
Notifications
You must be signed in to change notification settings - Fork 857
[16.0][ADD] account_move_group_restriction #2191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AungKoKoLin1997
wants to merge
1
commit into
OCA:16.0
Choose a base branch
from
qrtl:16.0-add-account_move_group_restriction
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| ========================================= | ||
| Account Move Restricted by Account Groups | ||
| ========================================= | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:933c2ca3272ccf0dd85bb6c838cee69ba99b8a2366f20cbb46fe18b36a1652ad | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/account-financial-tools/tree/16.0/account_move_group_restriction | ||
| :alt: OCA/account-financial-tools | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_group_restriction | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module adds an Access Groups field on accounts. When set, only | ||
| users in the selected groups can view journal entries and journal items | ||
| that use those accounts. | ||
|
|
||
| In standard Odoo, accounting users can generally access all journal | ||
| entries and items. In some cases, even certain accounting managers | ||
| should not see specific entries because they contain confidential | ||
| information. This module fills that gap by enforcing account-based | ||
| visibility rules. | ||
|
|
||
| Note: The groups set on accounts are intended to be additional to the | ||
| standard account.group_account_user, so users still keep basic | ||
| accounting access. For this reason, the module also provides a default | ||
| group, Accounting / View Restricted Accounts, which implies | ||
| account.group_account_user. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| If a journal entry includes lines on accounts restricted by different | ||
| access groups, the entry is accessible to any user who belongs to at | ||
| least one (not all) of those groups. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_group_restriction%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Quartile | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `Quartile <https://www.quartile.co>`__: | ||
|
|
||
| - Tatsuki Kanda | ||
| - Aung Ko Ko Lin | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| .. |maintainer-kanda999| image:: https://github.com/kanda999.png?size=40px | ||
| :target: https://github.com/kanda999 | ||
| :alt: kanda999 | ||
| .. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px | ||
| :target: https://github.com/aungkokolin1997 | ||
| :alt: aungkokolin1997 | ||
|
|
||
| Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-kanda999| |maintainer-aungkokolin1997| | ||
|
|
||
| This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_move_group_restriction>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Account Move Restricted by Account Groups", | ||
| "summary": "Restrict visibility of journal entries by security groups on accounts.", | ||
| "version": "16.0.1.0.0", | ||
| "category": "Accounting", | ||
| "author": "Quartile, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/account-financial-tools", | ||
| "license": "AGPL-3", | ||
| "depends": ["account"], | ||
| "data": [ | ||
| "security/account_move_group_restriction_security.xml", | ||
| "views/account_account_view.xml", | ||
| ], | ||
| "maintainers": ["kanda999", "aungkokolin1997"], | ||
| "installable": True, | ||
| "application": False, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import account_account | ||
| from . import account_move |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class AccountAccount(models.Model): | ||
| _inherit = "account.account" | ||
|
|
||
| security_group_ids = fields.Many2many( | ||
| comodel_name="res.groups", | ||
| relation="account_account_res_groups_rel", | ||
| column1="account_id", | ||
| column2="group_id", | ||
| string="Access Groups", | ||
| help=( | ||
| "If set, only users belonging to at least one of these groups " | ||
| "will be able to see journal items and journal entries " | ||
| "posting on this account. " | ||
| "If left empty, the account is visible to all accounting users." | ||
| ), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Copyright 2025 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
|
|
||
| from odoo import Command, api, fields, models | ||
|
|
||
|
|
||
| class AccountMove(models.Model): | ||
| _inherit = "account.move" | ||
|
|
||
| account_security_group_ids = fields.Many2many( | ||
| comodel_name="res.groups", | ||
| relation="account_move_res_groups_rel", | ||
| column1="move_id", | ||
| column2="group_id", | ||
| string="Account Access Groups", | ||
| compute="_compute_account_security_group_ids", | ||
| compute_sudo=True, | ||
| store=True, | ||
| help=( | ||
| "Union of the security groups configured on the accounts used " | ||
| "on this journal entry. Used by record rules to restrict access: " | ||
| "if any line uses a restricted account, the whole move becomes " | ||
| "visible only to users in at least one of these groups." | ||
| ), | ||
| ) | ||
|
|
||
| @api.depends("line_ids.account_id.security_group_ids") | ||
| def _compute_account_security_group_ids(self): | ||
| for move in self: | ||
| groups = move.mapped("line_ids.account_id.security_group_ids") | ||
| move.account_security_group_ids = [Command.set(groups.ids)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - [Quartile](https://www.quartile.co): | ||
| - Tatsuki Kanda | ||
| - Aung Ko Ko Lin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| This module adds an Access Groups field on accounts. When set, only users in the | ||
| selected groups can view journal entries and journal items that use those accounts. | ||
|
|
||
| In standard Odoo, accounting users can generally access all journal entries and items. | ||
| In some cases, even certain accounting managers should not see specific entries because | ||
| they contain confidential information. This module fills that gap by enforcing | ||
| account-based visibility rules. | ||
|
|
||
| Note: The groups set on accounts are intended to be additional to the standard | ||
| account.group_account_user, so users still keep basic accounting access. For this | ||
| reason, the module also provides a default group, Accounting / View Restricted Accounts, | ||
| which implies account.group_account_user. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| If a journal entry includes lines on accounts restricted by different access groups, the | ||
| entry is accessible to any user who belongs to at least one (not all) of those groups. |
41 changes: 41 additions & 0 deletions
41
account_move_group_restriction/security/account_move_group_restriction_security.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <odoo> | ||
| <record id="group_restricted_account_management" model="res.groups"> | ||
| <field name="name">Accounting / View Restricted Accounts</field> | ||
| <field name="category_id" ref="base.module_category_accounting_and_finance" /> | ||
| <field | ||
| name="implied_ids" | ||
| eval="[Command.link(ref('account.group_account_user'))]" | ||
| /> | ||
| </record> | ||
|
|
||
| <record id="account_move_line_account_group_rule" model="ir.rule"> | ||
| <field name="name">Account Move Line by Account Group</field> | ||
| <field name="model_id" ref="account.model_account_move_line" /> | ||
| <field name="domain_force"> | ||
| ['|', | ||
| ('move_id.account_security_group_ids', '=', False), | ||
| ('move_id.account_security_group_ids', 'in', user.groups_id.ids) | ||
| ] | ||
| </field> | ||
| <field name="perm_read" eval="True" /> | ||
| <field name="perm_write" eval="True" /> | ||
| <field name="perm_create" eval="True" /> | ||
| <field name="perm_unlink" eval="True" /> | ||
| </record> | ||
|
|
||
| <record id="account_move_account_group_rule" model="ir.rule"> | ||
| <field name="name">Account Move by Account Group</field> | ||
| <field name="model_id" ref="account.model_account_move" /> | ||
| <field name="domain_force"> | ||
| ['|', | ||
| ('account_security_group_ids', '=', False), | ||
| ('account_security_group_ids', 'in', user.groups_id.ids) | ||
| ] | ||
| </field> | ||
| <field name="perm_read" eval="True" /> | ||
| <field name="perm_write" eval="True" /> | ||
| <field name="perm_create" eval="True" /> | ||
| <field name="perm_unlink" eval="True" /> | ||
| </record> | ||
| </odoo> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows users to access the move when they have ANY of the access groups involved (instead of all), which should not be something intended.
We may leave the design as is, since most use cases will involve only one such group, but we should add a ROADMAP.md to explain this limitation.