Skip to content

Commit

Permalink
[FIX] inrim App access register
Browse files Browse the repository at this point in the history
  • Loading branch information
archetipo committed Nov 15, 2024
1 parent f4e303c commit 58b0265
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions inrim_controllo_accessi/models/ca_anag_registro_accesso.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytz
from odoo import models, fields
import logging

logger = logging.getLogger(__name__)

_tzs = [(tz, tz) for tz in sorted(
pytz.all_timezones, key=lambda tz: tz if not tz.startswith('Etc/') else '_')]
Expand Down
9 changes: 5 additions & 4 deletions inrim_controllo_accessi/models/ca_punto_accesso.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from odoo import models, fields, api, _
from odoo.exceptions import UserError
import logging

logger = logging.getLogger(__name__)

class CaPuntoAccessoCategory(models.Model):
_name = 'ca.punto_accesso_category'
Expand Down Expand Up @@ -34,14 +36,11 @@ def action_add_guest(self):

def compute_ca_tag_persona_ids(self):
self.ensure_one()
# Ottieni i record di model_b associati al record corrente di model_a tramite field_b
access_point_ids = self.ca_access_point_ids

# Prendi gli IDs di model_c relativi ai record di model_b
access_point_ids = self.ca_access_point_ids
tag_persona_ids = access_point_ids.mapped(
'ca_tag_lettore_persona_ids.ca_tag_persona').ids # 'field_c_related' è il campo Many2many in ModelB

# Popola field_c in model_a con gli IDs di model_c
self.ca_tag_persona_ids = [(6, 0, tag_persona_ids)]


Expand Down Expand Up @@ -248,6 +247,7 @@ def stamping_detach(self, persona):
:return:
"""
logger.info(f"Detach {persona.name}")
tag = persona.get_current_tag()
lettore_persona = self.ca_tag_lettore_persona_ids.filtered(
lambda x: x.ca_persona_id.id == persona.id
Expand All @@ -264,6 +264,7 @@ def stamping_attach(self):
- aggiorno l'elenco delle persone collegate al lettore e quindi al punto accesso
:return:
"""
logger.info("Stamping Attach")
self.ensure_one()
tags = self.env['ca.tag'].search([
('name', 'in', [self.env.ref('inrim_anagrafiche.proprieta_tag_valido')])
Expand Down
11 changes: 8 additions & 3 deletions inrim_controllo_accessi/wizard/ca_registra_ospite.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import logging

from odoo import models, fields, api, _

logger = logging.getLogger(__name__)


class CaRegistraOspite(models.TransientModel):
_name = 'ca.registra_ospite'
Expand Down Expand Up @@ -194,8 +198,8 @@ def action_confirm(self):
'work_id_number': self.freshman,
'ca_work_info_type_id': self.ca_work_info_type_id.id,
'ca_title_id': self.ca_title_id.id,
'date_start':self.date_start.split(" ")[0],
'date_end':self.date_end.split(" ")[0]
'date_start': self.date_start.split(" ")[0],
'date_end': self.date_end.split(" ")[0]
}
)
else:
Expand All @@ -216,6 +220,7 @@ def action_confirm(self):
'date_end': self.date_end,
})
for access_point_group in self.env['ca.punto_accesso_category'].search([]):
for access_point in access_point_group.ca_access_point_ids:
for access_point in access_point_group.ca_access_point_ids.ids:
logger.info(f"wizard eval attach {access_point}")
access_point.stamping_attach()
return res

0 comments on commit 58b0265

Please sign in to comment.