diff --git a/views/res_partner.xml b/views/res_partner.xml index 9e55d8fea635a997628df74e55dc29a4d238ab84..3682f328124936cb1c30a288db114cd5329532f7 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -32,8 +32,6 @@ </group> <group string="ESS"> <field name="ess" /> - <field name="lib_ess" /> - <field name="date_ess" /> </group> </group> </page> diff --git a/wizard/wizard_siren.py b/wizard/wizard_siren.py index e566376af2bc818dbb5402a2e5293ecfa8ac8b84..7ccc2c90c04eccdc12a92fe7c879229c62c4d283 100644 --- a/wizard/wizard_siren.py +++ b/wizard/wizard_siren.py @@ -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']: - new_company = self.company_lines.create({ - 'wizard_id': self.id, - 'name': company['fields']['l1_normalisee'], - }) - 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('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": - 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"]: - new_company.effectif = 0 - else: - new_company.effectif = int(company['fields']['efetcent']) + if company['fields'].get('denominationunitelegale',False): + new_company = self.company_lines.create({ + 'wizard_id': self.id, + 'name': company['fields'].get('denominationunitelegale'), + }) + 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('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('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'].get('trancheeffectifsunitelegale')) return { "type": "ir.actions.do_nothing", } diff --git a/wizard/wizard_siren.xml b/wizard/wizard_siren.xml index 35f28ffcbc3669a10842a96e804d508438872c9f..3dd4408d7d7f10b353546c06c6cab9e5e2758f7e 100644 --- a/wizard/wizard_siren.xml +++ b/wizard/wizard_siren.xml @@ -54,8 +54,6 @@ </group> <group string="ESS"> <field name="ess" /> - <field name="lib_ess" /> - <field name="date_ess" /> </group> </group> <footer>