Skip to content
Extraits de code Groupes Projets
Valider 7549e6d0 rédigé par Benjamin's avatar Benjamin
Parcourir les fichiers

migration api v3

parent 00643965
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -32,8 +32,6 @@
</group>
<group string="ESS">
<field name="ess" />
<field name="lib_ess" />
<field name="date_ess" />
</group>
</group>
</page>
......
......@@ -9,7 +9,7 @@ import requests
from odoo import api, fields, models
URL = "https://data.opendatasoft.com/api/records/1.0/search/?dataset=sirene%40public&q="
URL = "https://data.opendatasoft.com/api/records/1.0/search/?dataset=sirene_v3%40public&q="
CHAMPS = "&rows=100"
class SirenWizard(models.TransientModel):
......@@ -28,6 +28,7 @@ class SirenWizard(models.TransientModel):
## Fields
name = fields.Char(string='Entreprise', default=_default_name)
city = fields.Char(string='Ville')
company_lines = fields.One2many('siren.wizard.company', 'wizard_id', string="Résultats",)
partner_id = fields.Integer('Partner', default=_default_partner)
......@@ -40,42 +41,39 @@ class SirenWizard(models.TransientModel):
companies = r.json()
# Unlink all company lines
self.company_lines.unlink()
# Fill new company lines
# Fill new company company_lines
for company in companies['records']:
if company['fields'].get('denominationunitelegale',False):
new_company = self.company_lines.create({
'wizard_id': self.id,
'name': company['fields']['l1_normalisee'],
'name': company['fields'].get('denominationunitelegale'),
})
if company['fields'].get('l4_normalisee'):
new_company.street = company['fields']['l4_normalisee']
if company['fields'].get('codpos'):
new_company.zip = company['fields']['codpos']
if company['fields'].get('libcom'):
new_company.city = company['fields']['libcom']
if company['fields'].get('adresseetablissement'):
new_company.street = company['fields']['adresseetablissement']
if company['fields'].get('codepostaletablissement'):
new_company.zip = company['fields']['codepostaletablissement']
if company['fields'].get('libellecommuneetablissement'):
new_company.city = company['fields']['libellecommuneetablissement']
if company['fields'].get('siren'):
new_company.siren = company['fields']['siren']
if company['fields'].get('siret'):
new_company.siret = company['fields']['siret']
if company['fields'].get('categorie'):
new_company.categorie = company['fields']['categorie']
if company['fields'].get('dcret'):
new_company.date_creation = company['fields']['dcret']
if company['fields'].get('apen700'):
new_company.ape = company['fields']['apen700']
if company['fields'].get('libapet'):
new_company.lib_ape = company['fields']['libapet']
if company['fields'].get('dateess'):
new_company.date_ess = company['fields']['dateess']
if company['fields'].get('ess') == "O":
if company['fields'].get('categorieentreprise'):
new_company.categorie = company['fields']['categorieentreprise']
if company['fields'].get('datecreationunitelegale'):
new_company.date_creation = company['fields']['datecreationunitelegale']
if company['fields'].get('activiteprincipaleunitelegale'):
new_company.ape = company['fields']['activiteprincipaleunitelegale']
if company['fields'].get('divisionunitelegale'):
new_company.lib_ape = company['fields']['divisionunitelegale']
if company['fields'].get('economiesocialesolidaireunitelegale') == "O":
new_company.ess = True
if company['fields'].get('libessen'):
new_company.lib_ess = company['fields']['libessen']
if company['fields'].get('libnj'):
new_company.forme_juridique = company['fields']['libnj']
if company['fields']['efetcent'] in ["NN","0"]:
if company['fields'].get('naturejuridiqueunitelegale'):
new_company.forme_juridique = company['fields']['naturejuridiqueunitelegale']
if company['fields'].get('trancheeffectifsunitelegale', "0") in ["NN","0"]:
new_company.effectif = 0
else:
new_company.effectif = int(company['fields']['efetcent'])
new_company.effectif = int(company['fields'].get('trancheeffectifsunitelegale'))
return { "type": "ir.actions.do_nothing", }
......
......@@ -54,8 +54,6 @@
</group>
<group string="ESS">
<field name="ess" />
<field name="lib_ess" />
<field name="date_ess" />
</group>
</group>
<footer>
......
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