Skip to content

Commit 7fe66f8

Browse files
committed
[FIX] account_journal_security: archived users restrictions, visible but not selectable
1 parent b92c2c2 commit 7fe66f8

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

account_journal_security/models/account_journal.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AccountJournal(models.Model):
1919
help='If choose some users, then this journal and the information'
2020
' related to it will be only visible for those users.',
2121
copy=False,
22+
context={'active_test': False},
2223
)
2324

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

3638
journal_restriction = fields.Selection(

account_journal_security/models/res_users.py

-12
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,3 @@ class Users(models.Model):
2626
'Modification Journals',
2727
context={'active_test': False},
2828
)
29-
30-
# Cuando un usuario es archivado limpiamos los campos modification_journal_ids
31-
# y journal_ids para evitar problemas, ya que en el metodo unset_modification_user_ids(self)
32-
# no se limpiaban los usuarios archivados.
33-
# TODO ver mejora para v15 (posible compute/inverse)
34-
def write(self, vals):
35-
if 'active' in vals and not vals.get('active'):
36-
vals.update({
37-
'modification_journal_ids': [(5, 0, 0)],
38-
'journal_ids': [(5, 0, 0)],
39-
})
40-
return super().write(vals)

account_journal_security/views/account_journal_views.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
<xpath expr="//page[@name='advanced_settings']/group" position="inside">
99
<group string="Restringir a Usuarios">
1010
<field name="journal_restriction" widget="radio" groups="base.group_erp_manager"/>
11-
<field name="user_ids" widget="many2many_tags" groups="base.group_erp_manager" attrs="{'invisible': [('journal_restriction', '!=', 'total')]}"/>
12-
<field name="modification_user_ids" widget="many2many_tags" groups="base.group_erp_manager" attrs="{'invisible': [('journal_restriction', '!=', 'modification')]}"/>
11+
<field name="user_ids" widget="many2many_tags" groups="base.group_erp_manager"
12+
attrs="{'invisible': [('journal_restriction', '!=', 'total')]}"
13+
context="{'search_default_no_share': True, 'search_default_active': True}"/>
14+
<field name="modification_user_ids" widget="many2many_tags" groups="base.group_erp_manager"
15+
attrs="{'invisible': [('journal_restriction', '!=', 'modification')]}"
16+
context="{'search_default_no_share': True, 'search_default_active': True}"/>
1317
<div class="alert alert-warning" attrs="{'invisible': [('journal_restriction', '!=', 'total')]}" colspan="2" role="alert">
1418
<p>
1519
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.

0 commit comments

Comments
 (0)