@@ -19,6 +19,7 @@ class AccountJournal(models.Model):
19
19
help = 'If choose some users, then this journal and the information'
20
20
' related to it will be only visible for those users.' ,
21
21
copy = False ,
22
+ context = {'active_test' : False },
22
23
)
23
24
24
25
modification_user_ids = fields .Many2many (
@@ -31,6 +32,7 @@ class AccountJournal(models.Model):
31
32
' create, write or delete accounting data related of this journal. '
32
33
'Information will still be visible for other users.' ,
33
34
copy = False ,
35
+ context = {'active_test' : False },
34
36
)
35
37
36
38
journal_restriction = fields .Selection (
@@ -39,10 +41,10 @@ class AccountJournal(models.Model):
39
41
('total' , 'Total' )],
40
42
string = "Tipo de Restriccion" ,
41
43
compute = '_compute_journal_restriction' ,
42
- readonly = False ,
44
+ inverse = '_inverse_unset_modification_user_ids' ,
43
45
)
44
46
45
- @api .depends ()
47
+ @api .depends ('user_ids' , 'modification_user_ids' )
46
48
def _compute_journal_restriction (self ):
47
49
for rec in self :
48
50
if rec .user_ids :
@@ -111,18 +113,18 @@ def _search(self, args, offset=0, limit=None, order=None, count=False, access_ri
111
113
return super ()._search (args , offset , limit , order , count = count , access_rights_uid = access_rights_uid )
112
114
113
115
@api .onchange ('journal_restriction' )
114
- def unset_modification_user_ids (self ):
116
+ def _inverse_unset_modification_user_ids (self ):
115
117
"""
116
118
Al cambiar una opción por otra, limpiar el campo M2M
117
119
que se oculta para evitar conflictos al guardar.
118
120
"""
119
- if self .journal_restriction == 'modification' :
121
+ if self .journal_restriction == 'modification' and self . user_ids :
120
122
self .modification_user_ids = self .user_ids
121
123
self .user_ids = None
122
- elif self .journal_restriction == 'total' :
124
+ elif self .journal_restriction == 'total' and self . modification_user_ids :
123
125
self .user_ids = self .modification_user_ids
124
126
self .modification_user_ids = None
125
- else :
127
+ elif self . journal_restriction == 'none' :
126
128
# Es necesario que se limpien ambos campos cuando se seleccione
127
129
# "Ninguna", sino no se guardan los cambios.
128
130
self .user_ids = None
0 commit comments