Skip to content

Commit

Permalink
[MIG] account_journal_security: Migration to 17.0
Browse files Browse the repository at this point in the history
closes #475

Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
pablohmontenegro committed Dec 15, 2023
1 parent 943f765 commit dd1a247
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions account_journal_security/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Journal Security',
'version': "16.0.1.0.0",
'version': "17.0.1.0.0",
'category': 'Accounting',
'sequence': 14,
'summary': 'Restrict the use of certain journals to certain users',
Expand All @@ -39,7 +39,7 @@
],
'test': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
19 changes: 9 additions & 10 deletions account_journal_security/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def _check_journal_users_restriction(self, field):
"""
# esto es porque las ir rules tienen un cache que no permite
# que el cambio aplique en el momento
self.env['ir.rule'].clear_caches()
self.env.flush_all()
self.env.registry.clear_cache()

# FIXME: Con el onchange de journal_restriction esto
# ya no debería ocurrir.
Expand All @@ -91,24 +92,22 @@ def _check_journal_users_restriction(self, field):
'inclurise a usted mismo ya que dejaria de ver este '
'diario') % (rec.name))
# necesitamos limpiar este cache para que no deje de verlo
self.env.user.context_get.clear_cache(self)
self.env.flush_all()
self.env.registry.clear_cache()

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=None):
"""
Para que usuarios los usuarios no puedan elegir diarios donde no puedan
escribir, modificamos la funcion search. No lo hacemos por regla de
permiso ya que si no pueden ver los diarios termina dando errores en
cualquier lugar que se use un campo related a algo del diario
"""
user = self.env.user
# if superadmin, do not apply
if not self.env.is_superuser():
args += [
'|', ('modification_user_ids', '=', False),
('id', 'in', user.modification_journal_ids.ids)]

return super()._search(args, offset, limit, order, count=count, access_rights_uid=access_rights_uid)
domain += [
'|', ('modification_user_ids', '=', False),
('id', 'in', user.modification_journal_ids.ids)]
return super()._search(domain, offset, limit, order, access_rights_uid=access_rights_uid)

@api.onchange('journal_restriction')
def unset_modification_user_ids(self):
Expand Down
6 changes: 3 additions & 3 deletions account_journal_security/views/account_journal_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<group string="Restringir a Usuarios">
<field name="journal_restriction" invisible="1"/>
<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')]}"/>
<div class="alert alert-warning" attrs="{'invisible': [('journal_restriction', '!=', 'total')]}" colspan="2" role="alert">
<field name="user_ids" widget="many2many_tags" groups="base.group_erp_manager" invisible="journal_restriction != 'total'"/>
<field name="modification_user_ids" widget="many2many_tags" groups="base.group_erp_manager" invisible="journal_restriction != 'modification'"/>
<div class="alert alert-warning" invisible="journal_restriction != 'total'" colspan="2" role="alert">
<p>
<b>IMPORTANTE:</b> Los usuarios que no estén en la lista no podrán ver facturas, pagos, asiento o apuntes contables en este diario, pero si podrán ver información relativa a este diario en, por ejemplo, resumen de cuenta, detalle de deuda e informes contables.
</p>
Expand Down

0 comments on commit dd1a247

Please sign in to comment.