Skip to content

Commit

Permalink
[FIX] sync users
Browse files Browse the repository at this point in the history
  • Loading branch information
archetipo committed Dec 13, 2024
1 parent 154d6dc commit 7bd3f0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions controllo_accessi_inrim_app/models/ca_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests
from odoo import models, api, fields
from odoo.addons.test_convert.tests.test_env import record

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -239,6 +240,7 @@ def make_user_todo(self, record):
logger.info(f" make persona {record.get('matricola')} In progress ")
esterno = self.env.ref(
'inrim_anagrafiche.tipo_persona_esterno').id
ext_entity = 'entiesterni_tipopersonale'
ext_winfo_type = self.env['ca.work_info_type'].get_by_code(
ext_entity)
ext_job_title_code = "esterno_jobtitles"
Expand All @@ -250,7 +252,7 @@ def make_user_todo(self, record):
'controllo_accessi_inrim_app.inrim_azienda_esterna_da_gestire')
base_default_ente_todo = self.env.ref(
'controllo_accessi_inrim_app.inrim_ente_esterno_da_gestire')

codice_fiscale = record.get('cf')
azienda_ids = [base_default_ente_todo.id]
type_ids = [esterno]
persona_id = self.env['ca.persona'].with_context(
Expand All @@ -260,10 +262,10 @@ def make_user_todo(self, record):

if not persona_id:
vals = {
'name': nome,
'lastname': cognome,
'name': record.get('nome').capitalize(),
'lastname': record.get('cognome').capitalize(),
'freshman': record.get('matricola'),
'fiscalcode': record.get('cf'),
'fiscalcode': codice_fiscale,
'type_ids': type_ids,
'ca_ente_azienda_ids': azienda_ids,
"send_to_payroll_system": record['sync'] == 'y'
Expand All @@ -280,7 +282,7 @@ def make_user_todo(self, record):
'ca_work_info_type_id': ext_winfo_type.id,
'ca_title_id': ext_job_title.id,
'date_start': self.to_date(default_date_start),
'date_end': self.to_date(date_end)
'date_end': date_end
}

if (
Expand Down
4 changes: 3 additions & 1 deletion inrim_anagrafiche/models/ca_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ def update_work_info(self, vals):

@api.constrains('is_external', 'parent_id')
def _check_external_and_parent_id(self):
check = False
for record in self:
if (
record.is_external and
not record.parent_id and
not self.env.context.get("massive_create")
not self.env.context.get("massive_create") and
check
):
raise ValidationError(
_("For External person Internal reference is required "))
Expand Down

0 comments on commit 7bd3f0c

Please sign in to comment.