Exporter les données d'entreprise Odoo via un point de terminaison d'API, avec des options de sortie JSON/Excel

Avancé

Ceci est unCRMworkflow d'automatisation du domainecontenant 18 nœuds.Utilise principalement des nœuds comme If, Code, Odoo, Webhook, Function. Exporter les données d'entreprise Odoo via un endpoint API, avec options de sortie JSON/Excel

Prérequis
  • Point de terminaison HTTP Webhook (généré automatiquement par n8n)

Catégorie

Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "meta": {
    "instanceId": "6b3e8c6c30cdfbf06283a3fa57016932c6b4ec959896c5c546ef5865ff697ff1"
  },
  "nodes": [
    {
      "id": "2b167f16-af65-4d8f-9a83-3dff9c06f99c",
      "name": "Recevoir la demande d'entreprise",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -624,
        1424
      ],
      "webhookId": "get-companies-uuid",
      "parameters": {
        "path": "/api/v1/get-companies",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b73f4dcc-6335-4458-a5d5-b6fa578dfed2",
      "name": "Préparer le filtre dynamique",
      "type": "n8n-nodes-base.function",
      "position": [
        -384,
        1424
      ],
      "parameters": {
        "functionCode": "// const query = $json[\"query\"] || {}\n// const filters = []\n// if (query.name) filters.push([\"name\", \"ilike\", query.name])\n// if (query.country) filters.push([\"country_code\", \"=\", query.country])\n// const limit = query.limit ? parseInt(query.limit) : 25\n// const response_format = query.response_format || 'json'\n// return [{ json: { filters, limit, response_format } }]\n\nconst query = $json[\"query\"] || {};\n\n// Validate required 'name' parameter\nif (!query.name || query.name.trim() === \"\") {\n  return [\n    {\n      json: {\n        success: false,\n        message: \"Missing required parameter: name\",\n      },\n    },\n  ];\n}\n\nconst filters = [];\nfilters.push([\"name\", \"ilike\", query.name]); // name is mandatory\n\nconst response_format = query.response_format || \"json\";\n\nreturn [\n  {\n    json: { filters, response_format },\n  },\n];"
      },
      "typeVersion": 1
    },
    {
      "id": "5676cb5c-2ddd-46fa-88d3-3902a183f227",
      "name": "Récupérer les entreprises depuis Odoo",
      "type": "n8n-nodes-base.odoo",
      "position": [
        -128,
        1424
      ],
      "parameters": {
        "options": {
          "fieldsList": [
            "display_name",
            "name",
            "email",
            "phone",
            "mobile",
            "parent_id",
            "partner_id",
            "country_code",
            "country_id"
          ]
        },
        "resource": "custom",
        "operation": "getAll",
        "returnAll": true,
        "filterRequest": {
          "filter": [
            {
              "value": "={{ $json.filters[0][2] && $json.filters[0][2].toString().trim() !== '' ? $json.filters[0][2] : \"False\" }}",
              "operator": "like",
              "fieldName": "name"
            }
          ]
        },
        "customResource": "res.company"
      },
      "credentials": {
        "odooApi": {
          "id": "rhW7JbaWT0NTawBZ",
          "name": "IMM Odoo 18"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "288b5309-6f46-484f-9ab6-06e94bd7b74f",
      "name": "Préparer les données de sortie",
      "type": "n8n-nodes-base.function",
      "position": [
        176,
        1424
      ],
      "parameters": {
        "functionCode": "if (items.length === 0 || Object.keys(items[0].json).length === 0) {\n  return [{ json: { success: false, message: 'No matching company records found' } }]\n}\nconst data = items.map(item => ({ ...item.json, report_generated_on: new Date().toISOString() }))\nreturn data.map(d => ({ json: d }))"
      },
      "typeVersion": 1
    },
    {
      "id": "cd151c5b-55ec-454a-b43d-b78a39b74441",
      "name": "Vérifier si Excel est requis",
      "type": "n8n-nodes-base.if",
      "position": [
        480,
        1424
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Prepare Dynamic Filter').item.json.response_format }}",
              "value2": "excel"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6b9e1c86-81c3-475a-bdda-1a44bc9aed4e",
      "name": "Convertir en Excel",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1104,
        1376
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1.1
    },
    {
      "id": "38164711-9c8c-4f7c-8e3b-3f19b1c12360",
      "name": "Répondre avec le fichier",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1392,
        1376
      ],
      "parameters": {
        "options": {},
        "respondWith": "binary"
      },
      "typeVersion": 1.4
    },
    {
      "id": "cba096d5-0e19-4bec-930e-eefe587e996e",
      "name": "Répondre avec JSON",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        784,
        1776
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.4
    },
    {
      "id": "5f3f46b8-330a-4594-8170-6b2e8d68b685",
      "name": "Note d'aperçu",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        592
      ],
      "parameters": {
        "width": 900,
        "height": 572,
        "content": "## How it works\nThis workflow provides an API endpoint `/api/v1/get-companies` that retrieves company records directly from your Odoo database. It’s built for teams who need to query or export company data — either as structured JSON for integrations or as Excel (.xlsx) for business reporting.\n\nWhen a request is made, the workflow:\n1. Accepts query parameters (`name`, `response_format`).\n2. Validates the name input (required for company search).\n3. Fetches all matching companies from Odoo using a partial `Like` filter.\n4. Returns results as a JSON response or Excel download depending on the `response_format` parameter.\n\nThis makes it ideal for quick data exports or syncing company information across systems.\n\n\n\n## Setup steps\n1. Open the Webhook node and note the endpoint `/api/v1/get-companies`.\n2. Connect your Odoo API credentials in the Odoo node.\n3. Optionally update the `fieldsList` in the Odoo node to include more company details (VAT, address, etc.).\n4. Test using a browser or Postman:  \n   - `/api/v1/get-companies?name=Tech&response_format=json`  \n   - `/api/v1/get-companies?name=Tech&response_format=excel`"
      },
      "typeVersion": 1
    },
    {
      "id": "c495e6f3-9186-41ec-8994-28ba95bde11b",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        1392
      ],
      "parameters": {
        "jsCode": "return $input.all()"
      },
      "typeVersion": 2
    },
    {
      "id": "d29068b1-e243-420b-b00c-24f9ecaa0512",
      "name": "Note d'aperçu10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 452,
        "height": 428,
        "content": "## Request & Validation\nReceives the API request and checks for the required “name” parameter.\nReturns a validation message if missing."
      },
      "typeVersion": 1
    },
    {
      "id": "285429ca-c751-4970-85ce-27289180f9c8",
      "name": "Note d'aperçu11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Search Records from Odoo\n- Queries `res.company` \n**Company Table** records in Odoo using “Like” for partial matches.\n- Customize the fields in the node options if needed.\n- **Note: Name search is case-sensitive.**"
      },
      "typeVersion": 1
    },
    {
      "id": "5f9b217d-9cf1-4a7d-b99a-c6640d38399b",
      "name": "Note d'aperçu12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Prepare data and manage response json object."
      },
      "typeVersion": 1
    },
    {
      "id": "e7a97e7d-928b-4ec3-88c7-d6a2ecee9ea9",
      "name": "Note d'aperçu13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Check response_format\nIf response_format=excel → returns a downloadable Excel file.\nOtherwise, returns JSON with company data."
      },
      "typeVersion": 1
    },
    {
      "id": "2d754c32-7a53-4a43-a49e-8ccf8839f6f8",
      "name": "Note d'aperçu14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Prepare Data for Binary file."
      },
      "typeVersion": 1
    },
    {
      "id": "0edb17ef-3bac-42fc-835d-d67e26ad82b0",
      "name": "Note d'aperçu15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Create excel file"
      },
      "typeVersion": 1
    },
    {
      "id": "6ab323ca-5cc5-4d86-b32d-17f7340a4ab2",
      "name": "Note d'aperçu16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 428,
        "content": "## Response to web-hook with excel file."
      },
      "typeVersion": 1
    },
    {
      "id": "9d469fdf-7eaa-452f-874a-552299170c51",
      "name": "Note d'aperçu17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        1632
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Response to web-hook with json object."
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "c495e6f3-9186-41ec-8994-28ba95bde11b": {
      "main": [
        [
          {
            "node": "6b9e1c86-81c3-475a-bdda-1a44bc9aed4e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6b9e1c86-81c3-475a-bdda-1a44bc9aed4e": {
      "main": [
        [
          {
            "node": "38164711-9c8c-4f7c-8e3b-3f19b1c12360",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "288b5309-6f46-484f-9ab6-06e94bd7b74f": {
      "main": [
        [
          {
            "node": "cd151c5b-55ec-454a-b43d-b78a39b74441",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b73f4dcc-6335-4458-a5d5-b6fa578dfed2": {
      "main": [
        [
          {
            "node": "5676cb5c-2ddd-46fa-88d3-3902a183f227",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cd151c5b-55ec-454a-b43d-b78a39b74441": {
      "main": [
        [
          {
            "node": "c495e6f3-9186-41ec-8994-28ba95bde11b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "cba096d5-0e19-4bec-930e-eefe587e996e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2b167f16-af65-4d8f-9a83-3dff9c06f99c": {
      "main": [
        [
          {
            "node": "b73f4dcc-6335-4458-a5d5-b6fa578dfed2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5676cb5c-2ddd-46fa-88d3-3902a183f227": {
      "main": [
        [
          {
            "node": "288b5309-6f46-484f-9ab6-06e94bd7b74f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - CRM

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds18
Catégorie1
Types de nœuds8
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Auteur
V3 Code Studio

V3 Code Studio

@v3codestudio

🚀 AI & Automation Expert | n8n Creator | Workflow Specialist | Automation Specialist | V3 Code Studio I build smart automation workflows with n8n to help businesses streamline operations, save time, and increase productivity. Passionate about no-code/low-code automation and AI-driven solutions that make processes efficient, scalable, and growth-oriented.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34