Skip to content

Commit

Permalink
[FIX] decoding access data json
Browse files Browse the repository at this point in the history
  • Loading branch information
archetipo committed Dec 5, 2024
1 parent d6f6367 commit 2c192e4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
18 changes: 9 additions & 9 deletions inrim_anagrafiche/models/ca_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class CaPersona(models.Model):
residence_city = fields.Char(
compute='_compute_residence_city', readonly=False, store=True
)
residence_zip = fields.Char(
compute='_compute_residence_zip',
readonly=False, store=True
)
residence_state_id = fields.Many2one(
'res.country.state',
domain="[('country_id', '=?', residence_country_id)]",
compute='_compute_residence_state_id', readonly=False, store=True
)
residence_zip = fields.Char(
compute='_compute_residence_zip',
readonly=False, store=True
)
residence_country_id = fields.Many2one(
'res.country', compute='_compute_residence_country_id',
readonly=False, store=True
Expand Down Expand Up @@ -211,7 +211,7 @@ def _compute_bool(self):
if interno_id in record.type_ids.ids:
record.is_internal = True
elif (
esterno_id in record.type_ids.ids
esterno_id in record.type_ids.ids
):
record.is_external = True

Expand Down Expand Up @@ -512,9 +512,9 @@ def rest_get_record(self):
'associated_user_id': self.f_m2o(self.associated_user_id),
'domicile_street': self.domicile_street or "",
'domicile_street2': self.domicile_street2 or "",
'domicile_city_id': self.f_m2o(self.domicile_city_id),
'domicile_city': self.domicile_city or "",
'domicile_zip': self.domicile_zip or "",
'domicile_state_id': self.f_m2o(self.domicile_state_id),
'domicile_zip_id': self.f_m2o(self.domicile_zip_id),
'domicile_country_id': self.f_m2o(self.domicile_country_id),
'vat': self.vat or "",
'domicile_other_than_residence': self.domicile_other_than_residence,
Expand All @@ -524,9 +524,9 @@ def rest_get_record(self):
'token': self.token,
'residence_street': self.residence_street or "",
'residence_street2': self.residence_street2 or "",
'residence_city_id': self.f_m2o(self.residence_city_id),
'residence_city': self.residence_city or "",
'residence_zip': self.residence_zip or "",
'residence_state_id': self.f_m2o(self.residence_state_id),
'residence_zip_id': self.f_m2o(self.residence_zip_id),
'residence_country_id': self.f_m2o(self.residence_country_id),
'email': self.email,
'phone': self.phone,
Expand Down
7 changes: 0 additions & 7 deletions inrim_controllo_accessi/models/ca_tag_lettore.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ def create(self, vals):
record.ca_punto_accesso_id.remote_update = True
return res

def write(self, vals):
res = super(CaTagLettore, self).write(vals)
for record in self:
if record.ca_punto_accesso_id:
record.ca_punto_accesso_id.remote_update = True
return res

def unlink(self):
for record in self:
if record.ca_punto_accesso_id:
Expand Down
4 changes: 2 additions & 2 deletions inrim_controllo_accessi/wizard/ca_registra_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def _compute_available_tags(self):

self.compute_available_tags()

@api.depends("persona_id", "ca_title_id")
def compute_available_tags(self):
self.ensure_one()
if not self.ca_title_id.structured:
Expand Down Expand Up @@ -148,8 +149,7 @@ def _compute_eval_fiscalcode(self):
self.with_context(
no_change_person=True,
no_change_vat=True).populate_person(persona_id)
else:
self.reset_person()


@api.onchange('ca_tag_id')
def _compute_tag_id_number(self):
Expand Down
15 changes: 7 additions & 8 deletions inrim_controllo_accessi/wizard/ca_restituisci_badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ class CaRestituisciBadge(models.TransientModel):
_description = 'Restituisci Badge'

ca_tag_id = fields.Many2one('ca.tag', required=True)
temp = fields.Boolean()
tag_ids = fields.Many2many('ca.tag', compute="_compute_tag_ids")
temp = fields.Boolean(default=True)
tag_ids = fields.Many2many('ca.tag_persona', compute="_compute_tag_ids")
persona_id = fields.Many2one("ca.persona")

@api.depends('temp')
def _compute_tag_ids(self):
tag_model = self.env['ca.tag']
tag_model = self.env['ca.tag_persona']
for record in self:
ids = []
domain = [('in_use', '=', True)]
domain = [('state', '=', "to_give_back"), ('ca_tag_id.in_use', '=', True )]
if record.temp:
domain.append(('temp', '=', record.temp))
ids.append(
tag_model.search(domain).ids
)
domain.append(('ca_tag_id.temp', '=', record.temp))
ids = tag_model.search(domain).ids

record.tag_ids = [(6, 0, ids)]

@api.onchange('ca_tag_id')
Expand Down
26 changes: 18 additions & 8 deletions inrim_controllo_accessi_rfidglobal/models/ca_punto_accesso.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,24 @@ def decode_data(self, code, file_path):
('ca_tag_id.tag_code', '=', record.idd),
('state', '=', 'to_give_back')])
if tag_persona:
riga_accesso_model.aggiungi_riga_accesso(
self, tag_persona,
record.eventDateTime_to_utc(),
type="auto",
access_allowed=record.accessAllowed,
tz=self.tz
)
return True
lettore_persona = self.env['ca.lettore_persona'].search([
('ca_persona_id', '=', tag_persona.ca_persona_id.id),
('ca_lettore_id', '=', ca_lettore_id.ca_lettore_id.id),
('state', '=', "active")
])
if lettore_persona:
riga_accesso_model.aggiungi_riga_accesso(
self, tag_persona,
record.eventDateTime_to_utc(),
type="auto",
access_allowed=record.accessAllowed,
tz=self.tz
)
return True
else:
logger.error(
f"Association {record.idd} and {tag_persona.ca_persona_id.display_name} is expired in reader")
return False
else:
logger.error(
f"tag {record.idd} associated with no one ")
Expand Down

0 comments on commit 2c192e4

Please sign in to comment.