Skip to content

Commit

Permalink
[FIX] account_journal_security: archived users restrictions, visible …
Browse files Browse the repository at this point in the history
…but not selectable
  • Loading branch information
augusto-weiss committed Jan 28, 2022
1 parent b92c2c2 commit 7fe66f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 2 additions & 0 deletions account_journal_security/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AccountJournal(models.Model):
help='If choose some users, then this journal and the information'
' related to it will be only visible for those users.',
copy=False,
context={'active_test': False},
)

modification_user_ids = fields.Many2many(
Expand All @@ -31,6 +32,7 @@ class AccountJournal(models.Model):
' create, write or delete accounting data related of this journal. '
'Information will still be visible for other users.',
copy=False,
context={'active_test': False},
)

journal_restriction = fields.Selection(
Expand Down
12 changes: 0 additions & 12 deletions account_journal_security/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,3 @@ class Users(models.Model):
'Modification Journals',
context={'active_test': False},
)

# Cuando un usuario es archivado limpiamos los campos modification_journal_ids
# y journal_ids para evitar problemas, ya que en el metodo unset_modification_user_ids(self)
# no se limpiaban los usuarios archivados.
# TODO ver mejora para v15 (posible compute/inverse)
def write(self, vals):
if 'active' in vals and not vals.get('active'):
vals.update({
'modification_journal_ids': [(5, 0, 0)],
'journal_ids': [(5, 0, 0)],
})
return super().write(vals)
8 changes: 6 additions & 2 deletions account_journal_security/views/account_journal_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
<xpath expr="//page[@name='advanced_settings']/group" position="inside">
<group string="Restringir a Usuarios">
<field name="journal_restriction" widget="radio" groups="base.group_erp_manager"/>
<field name="user_ids" widget="many2many_tags" groups="base.group_erp_manager" attrs="{'invisible': [('journal_restriction', '!=', 'total')]}"/>
<field name="modification_user_ids" widget="many2many_tags" groups="base.group_erp_manager" attrs="{'invisible': [('journal_restriction', '!=', 'modification')]}"/>
<field name="user_ids" widget="many2many_tags" groups="base.group_erp_manager"
attrs="{'invisible': [('journal_restriction', '!=', 'total')]}"
context="{'search_default_no_share': True, 'search_default_active': True}"/>
<field name="modification_user_ids" widget="many2many_tags" groups="base.group_erp_manager"
attrs="{'invisible': [('journal_restriction', '!=', 'modification')]}"
context="{'search_default_no_share': True, 'search_default_active': True}"/>
<div class="alert alert-warning" attrs="{'invisible': [('journal_restriction', '!=', 'total')]}" colspan="2" role="alert">
<p>
Tenga mucho cuidado al elegir esta opción ya que puede bloquear acciones de odoo. No lo recomendamos para diarios de ventas, compras, liquidez o cualquier diario en el cual se generen registros desde otra acción. Un caso tipico para este tipo de restricción es el diario de sueldos.
Expand Down

0 comments on commit 7fe66f8

Please sign in to comment.