Skip to content
Extraits de code Groupes Projets
Valider 857ee502 rédigé par Julien - Le Filament's avatar Julien - Le Filament
Parcourir les fichiers

[UPD] use period in maj CJ

parent 199406a5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -391,18 +391,36 @@ class ResPartner(models.Model):
"""
logger.info(_(f"Update forme juridique for {self.name}: {self.siren}"))
current_period = self._get_current_period()
if not inpi_data.formality.content.personneMorale:
return self._get_current_period()
return current_period
inpi_forme_juridique = inpi_data.formality.content.personneMorale.identite.entreprise.formeJuridique
# check if full code in base
cj_id = self.env["res.partner.company.type"].search([("code_forme_juridique", "=", inpi_forme_juridique)])
# if not check if there is a "niveau 2" code in base, CG use only a few CJ code
if not cj_id:
cj_id = self.env["res.partner.company.type"].search([
("code_forme_juridique", "=", inpi_forme_juridique[:3])])
("code_forme_juridique", "=", inpi_forme_juridique[:2])])
if cj_id:
if cj_id and cj_id.id != self.partner_company_type_id.id:
self.partner_company_type_id = cj_id.id
period_values = self._get_values_from_period(current_period)
if new_period:
current_period.write(
{"end": datetime.datetime.now().date(), "end_reason": "adr"}
)
period_values["start"] = fields.Date.today()
period_values["partner_id"] = self.id
period_values["res_partner_company_type"] = cj_id.id
if new_period:
return self.env["scop.period"].with_context().create(period_values)
else:
current_period.write(period_values)
return self._get_current_period()
......@@ -477,7 +495,6 @@ class ResPartner(models.Model):
to_write[value] = inpi_address.get(value)
self.write(to_write)
if changing_period_values:
if new_period:
period.write(
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter