Browse Source

Sep 13 [FIX] : Bug Fixed 'account_restrict_journal'

pull/277/head
AjmalCybro 2 years ago
parent
commit
7dd4ed86c9
  1. 6
      account_restrict_journal/README.rst
  2. 13
      account_restrict_journal/__manifest__.py
  3. 5
      account_restrict_journal/doc/RELEASE_NOTES.md
  4. 2
      account_restrict_journal/models/__init__.py
  5. 53
      account_restrict_journal/models/account_move.py
  6. 62
      account_restrict_journal/models/account_payment_register.py
  7. 11
      account_restrict_journal/models/res_users.py
  8. 3
      account_restrict_journal/security/account_journal_security.xml
  9. 19
      account_restrict_journal/security/ir_rule.xml
  10. BIN
      account_restrict_journal/static/description/assets/modules/2.png
  11. BIN
      account_restrict_journal/static/description/assets/modules/3.png
  12. BIN
      account_restrict_journal/static/description/assets/modules/4.png
  13. BIN
      account_restrict_journal/static/description/assets/modules/6.png
  14. BIN
      account_restrict_journal/static/description/assets/screenshots/1.png
  15. BIN
      account_restrict_journal/static/description/assets/screenshots/10.png
  16. BIN
      account_restrict_journal/static/description/assets/screenshots/11.png
  17. BIN
      account_restrict_journal/static/description/assets/screenshots/12.png
  18. BIN
      account_restrict_journal/static/description/assets/screenshots/2.png
  19. BIN
      account_restrict_journal/static/description/assets/screenshots/3.png
  20. BIN
      account_restrict_journal/static/description/assets/screenshots/4.png
  21. BIN
      account_restrict_journal/static/description/assets/screenshots/5.png
  22. BIN
      account_restrict_journal/static/description/assets/screenshots/6.png
  23. BIN
      account_restrict_journal/static/description/assets/screenshots/7.png
  24. BIN
      account_restrict_journal/static/description/assets/screenshots/8.png
  25. BIN
      account_restrict_journal/static/description/assets/screenshots/9.png
  26. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_01.png
  27. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_02.png
  28. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_03.png
  29. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_04.png
  30. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_05.png
  31. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_06.png
  32. BIN
      account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_07.png
  33. BIN
      account_restrict_journal/static/description/assets/screenshots/hero.gif
  34. BIN
      account_restrict_journal/static/description/assets/screenshots/hero_gif.gif
  35. BIN
      account_restrict_journal/static/description/assets/screenshots/im1.png
  36. BIN
      account_restrict_journal/static/description/assets/screenshots/im2.png
  37. 1110
      account_restrict_journal/static/description/index.html
  38. 16
      account_restrict_journal/views/account_move_views.xml
  39. 8
      account_restrict_journal/views/res_users_views.xml

6
account_restrict_journal/README.rst

@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg .. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
Restrict Journal for Users Restrict Journal for Users
@ -17,11 +17,11 @@ Company
License License
------- -------
General Public License, Version 3 (LGPL v3). General Public License, Version 3 (LGPL v3).
(https://www.odoo.com/documentation/user/16.0/legal/licenses/licenses.html) (https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Credits Credits
------- -------
Developer: Sreeshanth V S @cybrosys, Contact: odoo@cybrosys.com Developer: (V16) Sreeshanth V S @cybrosys, Contact: odoo@cybrosys.com
Contacts Contacts
-------- --------

13
account_restrict_journal/__manifest__.py

@ -21,20 +21,21 @@
############################################################################# #############################################################################
{ {
'name': "Restrict Journal for Users", 'name': "Restrict Journal for Users",
"description": """ Restrict account journal for the "version": "16.0.2.1.1",
specific users to access allowed journals only""",
"summary": "User can select only allowed journals",
"category": "Accounting", "category": "Accounting",
"version": "16.0.1.0.0", "summary": "User can select only allowed journals",
"description": """ Restrict account journal for the specific users to
access allowed journals only""",
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',
'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': ['account', 'base'], 'depends': ['base', 'base_accounting_kit'],
'data': [ 'data': [
'security/account_journal_security.xml', 'security/account_journal_security.xml',
'security/ir_rule.xml', 'security/ir_rule.xml',
'views/res_users_views.xml' 'views/res_users_views.xml',
'views/account_move_views.xml'
], ],
'images': [ 'images': [
'static/description/banner.png'], 'static/description/banner.png'],

5
account_restrict_journal/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Restrict Journal for Users - Initial commit for Restrict Journal for Users
#### 11.09.2023
#### Version 16.0.2.1.1
#### UPDT
- Bug Fix and Change Functionality

2
account_restrict_journal/models/__init__.py

@ -19,4 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from . import account_move
from . import account_payment_register
from . import res_users from . import res_users

53
account_restrict_journal/models/account_move.py

@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
class AccountMove(models.Model):
"""Inherited model for checking the journal type in account.move."""
_inherit = 'account.move'
check_journal = fields.Boolean(string="Check Journal",
help="Compute field for check the current "
"record's journal type ",
compute="_compute_journal")
def _compute_journal(self):
"""Compute field for showing validation error for restricted journal's
records"""
self.check_journal = True
for rec in self.line_ids:
if rec.full_reconcile_id:
payment = self.env['account.payment.register'].search(
[('id', '=', rec.full_reconcile_id.id)])
if payment.journal_id.id in self.env.user.journal_ids.ids:
raise ValidationError(_('Restricted journals found.'))
if self.journal_id.id in self.env.user.journal_ids.ids:
raise ValidationError(_('Restricted journals found.'))
@api.onchange('partner_id')
def _onchange_partner_id(self):
"""Function for hiding restricted journals from account.move."""
if self.journal_id.id in self.env.user.journal_ids.ids:
self.journal_id = False
return super(AccountMove, self)._onchange_partner_id()

62
account_restrict_journal/models/account_payment_register.py

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, models
class AccountPaymentRegister(models.TransientModel):
""" Adding allowed journal in functionality"""
_inherit = 'account.payment.register'
@api.depends('payment_type', 'company_id', 'can_edit_wizard')
def _compute_available_journal_ids(self):
"""
Check all available journals on register payment.
"""
for wizard in self:
if wizard.can_edit_wizard:
batch = wizard._get_batches()[0]
wizard.available_journal_ids = wizard._get_batch_available_journals(
batch)
else:
wizard.available_journal_ids = self.env[
'account.journal'].search(
[('company_id', '=', wizard.company_id.id),
('type', 'in', ('bank', 'cash')),
('id', 'not in', self.env.user.journal_ids.ids)])
@api.model
def _get_batch_available_journals(self, batch_result):
""" Helper to compute the available journals based on the batch.
:param batch_result: A batch returned by '_get_batches'.
:return: A recordset of account.journal.
"""
payment_type = batch_result['payment_values']['payment_type']
company = batch_result['lines'].company_id
journals = self.env['account.journal'].search(
[('company_id', '=', company.id), ('type', 'in', ('bank', 'cash')),
('id', 'not in', self.env.user.journal_ids.ids)])
if payment_type == 'inbound':
return journals.filtered('inbound_payment_method_line_ids')
else:
return journals.filtered('outbound_payment_method_line_ids')

11
account_restrict_journal/models/res_users.py

@ -27,8 +27,17 @@ class ResUsers(models.Model):
_inherit = 'res.users' _inherit = 'res.users'
check_user = fields.Boolean(string="Check", compute='_compute_check_user',
help="Check the field is true or false")
journal_ids = fields.Many2many( journal_ids = fields.Many2many(
'account.journal', 'account.journal',
string='Allowed 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 _compute_check_user(self):
"""Function for viewing the page for restrict journal users."""
self.check_user = False
if (self.env.ref('account_restrict_journal.user_allowed_journal').id in
self.groups_id.mapped('id')):
self.check_user = True

3
account_restrict_journal/security/account_journal_security.xml

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<!-- New user group created for journal restriction-->
<record id="user_allowed_journal" model="res.groups"> <record id="user_allowed_journal" model="res.groups">
<field name="name">Restrict Journals</field> <field name="name">Restrict Journals</field>
<field name="category_id" ref="base.module_category_usability"/> <field name="category_id" ref="base.module_category_usability"/>
</record> </record>
</odoo> </odoo>

19
account_restrict_journal/security/ir_rule.xml

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<!-- 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"/>
<field name="domain_force">[('id','in', user.journal_ids.ids)] <field name="domain_force">[('id','not in', user.journal_ids.ids)]
</field> </field>
<field name="groups" <field name="groups"
eval="[(4, ref('account_restrict_journal.user_allowed_journal'))]"/> eval="[(4, ref('account_restrict_journal.user_allowed_journal'))]"/>
@ -14,4 +15,18 @@
<field name="active" <field name="active"
eval="True"/> eval="True"/>
</record> </record>
</odoo> <record id="account_payment_rule_users" model="ir.rule">
<field name="name">Account Payment Restrict on Users</field>
<field name="model_id" ref="account.model_account_payment"/>
<field name="domain_force">[('journal_id','not in', user.journal_ids.ids)]
</field>
<field name="groups"
eval="[(4, ref('account_restrict_journal.user_allowed_journal'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="active"
eval="True"/>
</record>
</odoo>

BIN
account_restrict_journal/static/description/assets/modules/2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 86 KiB

BIN
account_restrict_journal/static/description/assets/modules/3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 79 KiB

BIN
account_restrict_journal/static/description/assets/modules/4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 87 KiB

BIN
account_restrict_journal/static/description/assets/modules/6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 80 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/11.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/12.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_01.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_03.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_04.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_05.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_06.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/account_journal_restriction_07.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/hero.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/hero_gif.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/im1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
account_restrict_journal/static/description/assets/screenshots/im2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

1110
account_restrict_journal/static/description/index.html

File diff suppressed because it is too large

16
account_restrict_journal/views/account_move_views.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Added fields for check journal type -->
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form.inherit.account.restrict.journal
</field>
<field name="model">account.move</field>
<field name="mode">extension</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='currency_id']" position="after">
<field name="check_journal" invisible="1"/>
</xpath>
</field>
</record>
</odoo>

8
account_restrict_journal/views/res_users_views.xml

@ -2,18 +2,20 @@
<odoo> <odoo>
<!-- Added fields for accessible journals --> <!-- Added fields for accessible journals -->
<record id="view_users_form" model="ir.ui.view"> <record id="view_users_form" model="ir.ui.view">
<field name="name">view.users.form.inherit.account.restrict.journal</field> <field name="name">res.users.form.inherit.account.restrict.journal
</field>
<field name="model">res.users</field> <field name="model">res.users</field>
<field name="mode">extension</field> <field name="mode">extension</field>
<field name="inherit_id" ref="base.view_users_form"/> <field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//page[@name='security']" position="after"> <xpath expr="//page[@name='security']" position="after">
<page name="account_journal" string="Allowed Journal"> <page name="account_journal" string="Restricted Journal" attrs="{'invisible': [('check_user','=', False)]}">
<group> <group>
<field name="journal_ids" widget="many2many_tags"/> <field name="journal_ids" widget="many2many_tags"/>
<field name="check_user" invisible="1"/>
</group> </group>
</page> </page>
</xpath> </xpath>
</field> </field>
</record> </record>
</odoo> </odoo>

Loading…
Cancel
Save