Browse Source

Mar 15 [UPDT] : Updated 'account_restrict_journal'

pull/278/merge
AjmalCybro 1 year ago
parent
commit
89eba60d76
  1. 4
      account_restrict_journal/__manifest__.py
  2. 5
      account_restrict_journal/doc/RELEASE_NOTES.md
  3. 8
      account_restrict_journal/models/account_move.py
  4. 4
      account_restrict_journal/models/account_payment_register.py
  5. 27
      account_restrict_journal/models/res_users.py
  6. 3
      account_restrict_journal/security/ir_rule.xml

4
account_restrict_journal/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': "Restrict Journal for Users", 'name': "Restrict Journal for Users",
"version": "16.0.2.1.2", "version": "16.0.2.1.1",
"category": "Accounting", "category": "Accounting",
"summary": "User can select only allowed journals", "summary": "User can select only allowed journals",
"description": """ Restrict account journal for the specific users to "description": """ Restrict account journal for the specific users to
@ -30,7 +30,7 @@
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com", 'website': "https://www.cybrosys.com",
'depends': ['base', 'account'], 'depends': ['base','account'],
'data': [ 'data': [
'security/account_journal_security.xml', 'security/account_journal_security.xml',
'security/ir_rule.xml', 'security/ir_rule.xml',

5
account_restrict_journal/doc/RELEASE_NOTES.md

@ -9,8 +9,3 @@
#### Version 16.0.2.1.1 #### Version 16.0.2.1.1
#### UPDT #### UPDT
- Bug Fix and Change Functionality - Bug Fix and Change Functionality
#### 09.01.2024
#### Version 16.0.2.1.2
#### BUGFIX
- Solved the issue in enterprise and added extra conditions to validation error.

8
account_restrict_journal/models/account_move.py

@ -40,13 +40,9 @@ class AccountMove(models.Model):
if rec.full_reconcile_id: if rec.full_reconcile_id:
payment = self.env['account.payment.register'].search( payment = self.env['account.payment.register'].search(
[('id', '=', rec.full_reconcile_id.id)]) [('id', '=', rec.full_reconcile_id.id)])
if payment.journal_id.id in self.env.user.journal_ids.ids and \ if payment.journal_id.id in self.env.user.journal_ids.ids:
self.env.user.has_group(
"account_restrict_journal.user_allowed_journal"):
raise ValidationError(_('Restricted journals found.')) raise ValidationError(_('Restricted journals found.'))
if self.journal_id.id in self.env.user.journal_ids.ids and \ if self.journal_id.id in self.env.user.journal_ids.ids:
self.env.user.has_group(
"account_restrict_journal.user_allowed_journal"):
raise ValidationError(_('Restricted journals found.')) raise ValidationError(_('Restricted journals found.'))
@api.onchange('partner_id') @api.onchange('partner_id')

4
account_restrict_journal/models/account_payment_register.py

@ -35,8 +35,8 @@ class AccountPaymentRegister(models.TransientModel):
for wizard in self: for wizard in self:
if wizard.can_edit_wizard: if wizard.can_edit_wizard:
batch = wizard._get_batches()[0] batch = wizard._get_batches()[0]
wizard.available_journal_ids = \ wizard.available_journal_ids = wizard._get_batch_available_journals(
wizard._get_batch_available_journals(batch) batch)
else: else:
wizard.available_journal_ids = self.env[ wizard.available_journal_ids = self.env[
'account.journal'].search( 'account.journal'].search(

27
account_restrict_journal/models/res_users.py

@ -19,8 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from odoo import fields, models, _ from odoo import fields, models
from odoo.exceptions import ValidationError
class ResUsers(models.Model): class ResUsers(models.Model):
@ -31,33 +30,11 @@ class ResUsers(models.Model):
check_user = fields.Boolean(string="Check", compute='_compute_check_user', check_user = fields.Boolean(string="Check", compute='_compute_check_user',
help="Check the field is true or false") help="Check the field is true or false")
journal_ids = fields.Many2many( journal_ids = fields.Many2many(
'account.journal', 'account.journal', 'account_restrict_journal_journal_ids_rel',
string='Restricted Journals', string='Restricted Journals',
help='Only the selected journal will be visible' help='Only the selected journal will be visible'
' to the particular user') ' to the particular user')
def write(self, vals):
"""
Override the write method to restrict users with specific groups.
:param vals: Dictionary of field values to update.
:type vals: dict
:raises: ValidationError if the current user has both
'account_restrict_journal.user_allowed_journal'
and 'base.group_system' groups and attempts to restrict
journals of the Administrator.
:return: None
"""
super().write(vals)
if self.env.user.has_group(
'account_restrict_journal.user_allowed_journal') and \
self.env.user.has_group('base.group_system'):
user_groups = self.env.user.groups_id.filtered(
lambda g: g.name == 'Restrict Journals')
if user_groups:
raise ValidationError(
_("You are not allowed to restrict journals for the "
"Administrator."))
def _compute_check_user(self): def _compute_check_user(self):
"""Function for viewing the page for restrict journal users.""" """Function for viewing the page for restrict journal users."""
self.check_user = False self.check_user = False

3
account_restrict_journal/security/ir_rule.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<!-- Created new record rule on account_journal for created user group--> <!-- Created new record rule for created user group-->
<record id="account_journal_rule_users" model="ir.rule"> <record id="account_journal_rule_users" model="ir.rule">
<field name="name">Account Journal Restrict on Users</field> <field name="name">Account Journal Restrict on Users</field>
<field name="model_id" ref="account.model_account_journal"/> <field name="model_id" ref="account.model_account_journal"/>
@ -15,7 +15,6 @@
<field name="active" <field name="active"
eval="True"/> eval="True"/>
</record> </record>
<!-- Created new record rule on account_payment for created user group-->
<record id="account_payment_rule_users" model="ir.rule"> <record id="account_payment_rule_users" model="ir.rule">
<field name="name">Account Payment Restrict on Users</field> <field name="name">Account Payment Restrict on Users</field>
<field name="model_id" ref="account.model_account_payment"/> <field name="model_id" ref="account.model_account_payment"/>

Loading…
Cancel
Save