Enriching Excel-based company data with Odoo IDs – how to keep matching indexes?

Hi everyone :wave:

I’m working on a workflow where I process company data from an Excel file that looks like this:

[
  {
    "category_id": 483,
    "country_id": 75,
    "country_code": "FR",
    "country_name": "France",
    "Identifiant Kompass": "FRXXXXXXX",
    "Nom de l'entreprise": "Entreprise A",
    "Numéro d’enregistrement (Siret, Siren…)": "XXXXXXXXX XXXXX",
    "Numéro de TVA intracommunautaire": "FRXX XXXXXXXX",
    "Email": "",
    "Numéro de téléphone": "+33 XXXXXXXXX",
    "Site web": "https://www.entreprise-a.com",
    "Rue": "Adresse Rue A",
    "Complément d'adresse": "Complément A",
    "Code postal": "XXXXX",
    "Ville": "Ville A",
    "Département/District": "Département A",
    "Région": "Région A",
    "Pays": "France",
    "Effectif entreprise": "De 20 à 49",
    "company_size": "20_49",
    "Tranche du CA brut": "De 10 à 25 millions EUR",
    "revenue_range": "10m_25m",
    "Code NAF 2008": "XXXXZ",
    "employees": [
      {
        "Prénom": "Prénom1",
        "Nom": "Nom1",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 1",
        "Civilité": "M."
      },
      {
        "Prénom": "Prénom2",
        "Nom": "Nom2",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 2",
        "Civilité": "M."
      },
      {
        "Prénom": "Prénom3",
        "Nom": "Nom3",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 3",
        "Civilité": "M."
      },
      {
        "Prénom": "Prénom4",
        "Nom": "Nom4",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 4",
        "Civilité": "Mme"
      }
    ]
  },
  {
    "category_id": 483,
    "country_id": 75,
    "country_code": "FR",
    "country_name": "France",
    "Identifiant Kompass": "FRXXXXXXX",
    "Nom de l'entreprise": "Entreprise B",
    "Numéro d’enregistrement (Siret, Siren…)": "XXXXXXXXX XXXXX",
    "Numéro de TVA intracommunautaire": "FRXX XXXXXXXX",
    "Email": "[email protected],[email protected]",
    "Numéro de téléphone": "+33 XXXXXXXXX",
    "Site web": "https://www.entreprise-b.fr",
    "Rue": "Adresse Rue B",
    "Complément d'adresse": "Complément B",
    "Code postal": "XXXXX",
    "Ville": "Ville B",
    "Département/District": "Département B",
    "Région": "Région B",
    "Pays": "France",
    "Effectif entreprise": "De 0 à 9",
    "company_size": "0_9",
    "Tranche du CA brut": "De 1 à 2 millions EUR",
    "revenue_range": "1m_2m",
    "Code NAF 2008": "XXXXC",
    "employees": [
      {
        "Prénom": "Prénom1",
        "Nom": "Nom1",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 1",
        "Civilité": "M"
      }
    ]
  },
  {
    "category_id": 483,
    "country_id": 75,
    "country_code": "FR",
    "country_name": "France",
    "Identifiant Kompass": "FRXXXXXXX",
    "Nom de l'entreprise": "Entreprise C",
    "Numéro d’enregistrement (Siret, Siren…)": "XXXXXXXXX XXXXX",
    "Numéro de TVA intracommunautaire": "FRXX XXXXXXXX",
    "Email": "[email protected],[email protected],[email protected],[email protected]",
    "Numéro de téléphone": "+33 XXXXXXXXX",
    "Site web": "https://www.entreprise-c.fr",
    "Rue": "Adresse Rue C",
    "Complément d'adresse": "Complément C",
    "Code postal": "XXXXX",
    "Ville": "Ville C",
    "Département/District": "Département C",
    "Région": "Région C",
    "Pays": "France",
    "Effectif entreprise": "De 20 à 49",
    "company_size": "20_49",
    "Tranche du CA brut": "De 10 à 25 millions EUR",
    "revenue_range": "10m_25m",
    "Code NAF 2008": "XXXXZ",
    "employees": [
      {
        "Prénom": "Prénom1",
        "Nom": "Nom1",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 1",
        "Civilité": "Mme"
      },
      {
        "Prénom": "Prénom2",
        "Nom": "Nom2",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 2",
        "Civilité": "Mme"
      }
    ]
  },
  {
    "category_id": 483,
    "country_id": 75,
    "country_code": "FR",
    "country_name": "France",
    "Identifiant Kompass": "FRXXXXXXX",
    "Nom de l'entreprise": "Entreprise D",
    "Numéro d’enregistrement (Siret, Siren…)": "XXXXXXXXX XXXXX",
    "Numéro de TVA intracommunautaire": "FRXX XXXXXXXX",
    "Email": "",
    "Numéro de téléphone": "+33 XXXXXXXXX",
    "Site web": "https://www.entreprise-d.com",
    "Rue": "Adresse Rue D",
    "Complément d'adresse": "Complément D",
    "Code postal": "XXXXX",
    "Ville": "Ville D",
    "Département/District": "Département D",
    "Région": "Région D",
    "Pays": "France",
    "Effectif entreprise": "De 20 à 49",
    "company_size": "20_49",
    "Tranche du CA brut": "De 5 à 10 millions EUR",
    "revenue_range": "5m_10m",
    "Code NAF 2008": "XXXXZ",
    "employees": [
      {
        "Prénom": "Prénom1",
        "Nom": "Nom1",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 1",
        "Civilité": "M."
      },
      {
        "Prénom": "Prénom2",
        "Nom": "Nom2",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 2",
        "Civilité": "M."
      }
    ]
  },
  {
    "category_id": 483,
    "country_id": 75,
    "country_code": "FR",
    "country_name": "France",
    "Identifiant Kompass": "FRXXXXXXX",
    "Nom de l'entreprise": "Entreprise E",
    "Numéro d’enregistrement (Siret, Siren…)": "XXXXXXXXX XXXXX",
    "Numéro de TVA intracommunautaire": "FRXX XXXXXXXX",
    "Email": "",
    "Numéro de téléphone": "+33 XXXXXXXXX",
    "Site web": "https://www.entreprise-e.fr/",
    "Rue": "Adresse Rue E",
    "Complément d'adresse": "",
    "Code postal": "XXXXX",
    "Ville": "Ville E",
    "Département/District": "Département E",
    "Région": "Région E",
    "Pays": "France",
    "Effectif entreprise": "De 100 à 249",
    "company_size": "100_249",
    "Tranche du CA brut": "De 10 à 25 millions EUR",
    "revenue_range": "10m_25m",
    "Code NAF 2008": "XXXXZ",
    "employees": [
      {
        "Prénom": "Prénom1",
        "Nom": "Nom1",
        "Email direct dirigeant*": "[email protected]",
        "Libellé fonction locale": "Fonction 1",
        "Civilité": "M."
      }
    ]
  }
]

:dart: What I’m trying to do

I want to:

  1. Read this Excel data.
  2. Check each company’s SIRET in Odoo via an HTTP Request node.
  3. If found, get the company’s ID.
  4. If not found, create it and get its ID.
  5. Enrich each original company object with that corresponding ID (e.g., odoo_company_id field).

:x: The issue

Everything works fine except the final enrichment step.

If companies are both found and created in the same execution, the result mapping back the Odoo IDs to the original companies gets out of sync. IDs are not added to the correct company objects — the indexes seem mismatched.

:man_detective: What I tried (but didn’t help)

:brain: What I’m looking for

How can I recombine the results from both the “Found” and “Created” paths back into the original data while preserving the order?

Should I store metadata early on? Use Merge node in a clever way? Am I missing a good n8n pattern for this?

Thanks a lot for any ideas :pray:

:package: Workflow example

In this example, I have appointed fake results from HTTP requests. How would you do it ?

These should be the end results :

  • A → 0
  • B → 1
  • C → 3
  • D → 4
  • E → 2

But as we can see, it ends up being :

  • A → 3
  • B → 4
  • C → 0
  • D → 1
  • E → 2

I found an ugly workaround but do you have any idea of a simpler approach ?

hello @Gentleman9914

You can do it with some Merge nodes

1 Like

Hey there, thank you very much for this cleaner alternative!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.