diff --git a/account_journal_security/__manifest__.py b/account_journal_security/__manifest__.py index 8bd4a46c8..7e4cb3960 100644 --- a/account_journal_security/__manifest__.py +++ b/account_journal_security/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'Journal Security', - 'version': "13.0.1.0.0", + 'version': "13.0.1.1.0", 'category': 'Accounting', 'sequence': 14, 'summary': 'Restrict the use of certain journals to certain users', diff --git a/account_journal_security/models/account_journal.py b/account_journal_security/models/account_journal.py index 7a35ab9a0..7451d7cef 100644 --- a/account_journal_security/models/account_journal.py +++ b/account_journal_security/models/account_journal.py @@ -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( @@ -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( @@ -39,10 +41,10 @@ class AccountJournal(models.Model): ('total', 'Total')], string="Tipo de Restriccion", compute='_compute_journal_restriction', - readonly=False, + inverse='_inverse_unset_modification_user_ids', ) - @api.depends() + @api.depends('user_ids', 'modification_user_ids') def _compute_journal_restriction(self): for rec in self: if rec.user_ids: @@ -111,18 +113,18 @@ def _search(self, args, offset=0, limit=None, order=None, count=False, access_ri return super()._search(args, offset, limit, order, count=count, access_rights_uid=access_rights_uid) @api.onchange('journal_restriction') - def unset_modification_user_ids(self): + def _inverse_unset_modification_user_ids(self): """ Al cambiar una opción por otra, limpiar el campo M2M que se oculta para evitar conflictos al guardar. """ - if self.journal_restriction == 'modification': + if self.journal_restriction == 'modification' and self.user_ids: self.modification_user_ids = self.user_ids self.user_ids = None - elif self.journal_restriction == 'total': + elif self.journal_restriction == 'total' and self.modification_user_ids: self.user_ids = self.modification_user_ids self.modification_user_ids = None - else: + elif self.journal_restriction == 'none': # Es necesario que se limpien ambos campos cuando se seleccione # "Ninguna", sino no se guardan los cambios. self.user_ids = None diff --git a/account_journal_security/models/res_users.py b/account_journal_security/models/res_users.py index 6fd3439f8..4c88e759c 100644 --- a/account_journal_security/models/res_users.py +++ b/account_journal_security/models/res_users.py @@ -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) diff --git a/account_journal_security/views/account_journal_views.xml b/account_journal_security/views/account_journal_views.xml index c09cf0ba8..337311ed7 100755 --- a/account_journal_security/views/account_journal_views.xml +++ b/account_journal_security/views/account_journal_views.xml @@ -8,8 +8,12 @@ - - + +