Obtenir les données clients d'Odoo et les exporter en JSON ou Excel

Avancé

Ceci est unCRMworkflow d'automatisation du domainecontenant 18 nœuds.Utilise principalement des nœuds comme If, Code, Odoo, Webhook, Function. obtenirOdooclientdonnées并exportation为JSONouExcel

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": "752a1ab6-274c-4f09-9bf1-e2dba414aaf1",
      "name": "Recevoir la demande d'entreprise1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -816,
        3152
      ],
      "webhookId": "get-companies-uuid",
      "parameters": {
        "path": "/api/v1/get-customers",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "66762aac-2d62-4d59-9956-816476d0f92f",
      "name": "Préparer le filtre dynamique1",
      "type": "n8n-nodes-base.function",
      "position": [
        -576,
        3152
      ],
      "parameters": {
        "functionCode": "// const query = $json[\"query\"] || {}\n// const filters = []\n// if (query.name) filters.push([\"name\", \"Like\", 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\", \"Like\", 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": "e727d97c-678b-41b8-8db4-d1615c73a116",
      "name": "Préparer les données de sortie1",
      "type": "n8n-nodes-base.function",
      "position": [
        0,
        3152
      ],
      "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": "9187426f-d4d0-4461-af73-3f31cdb0cc17",
      "name": "Vérifier si Excel requis1",
      "type": "n8n-nodes-base.if",
      "position": [
        288,
        3152
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Prepare Dynamic Filter1').item.json.response_format }}",
              "value2": "excel"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ed6030ad-11f0-43f6-aee5-147ee0c055de",
      "name": "Convertir en Excel1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        896,
        3104
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0e6e1540-4c2e-45fe-a75a-6e511a95937b",
      "name": "Répondre avec fichier1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        3104
      ],
      "parameters": {
        "options": {},
        "respondWith": "binary"
      },
      "typeVersion": 1.4
    },
    {
      "id": "d64e68cf-c80c-4633-bc4f-614d572ca762",
      "name": "Répondre avec JSON1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        3504
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.4
    },
    {
      "id": "d2f28f28-a541-42d1-aaf8-94ab14723a53",
      "name": "Note d'aperçu1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        2288
      ],
      "parameters": {
        "width": 900,
        "height": 620,
        "content": "## How it works\nThis workflow provides an API endpoint `/api/v1/get-customers` that retrieves customer contact records directly from your Odoo instance. It’s designed for teams who need to query or export customer data on demand — either in JSON for integrations or Excel (.xlsx) for reporting.\n\nWhen a request is made, the workflow:\n1. Accepts query parameters (`name`, `response_format`).\n2. Validates the name input (required for search).\n3. Fetches all matching customers (non-companies) from Odoo using an `Like` filter for partial matches.\n4. Dynamically returns either a JSON response or an Excel file download depending on the `response_format` parameter.\n\nThis makes it ideal for quick data exports\n\n\n\n## Setup steps\n1. Open the Webhook node and note the endpoint `/api/v1/get-customers`.\n2. Configure your Odoo API credentials in the Odoo node.\n3. Optionally update the `fieldsList` in the Odoo node to include more contact fields (email, city, etc.).\n4. Test using a browser or Postman:  \n   - `/api/v1/get-customers?name=Demo&response_format=json`  \n   - `/api/v1/get-customers?name=Demo&response_format=excel`"
      },
      "typeVersion": 1
    },
    {
      "id": "ad743706-da44-436c-a330-96f289469989",
      "name": "Récupérer client",
      "type": "n8n-nodes-base.odoo",
      "position": [
        -320,
        3152
      ],
      "parameters": {
        "options": {
          "fieldsList": [
            "display_name",
            "name",
            "email",
            "phone",
            "mobile",
            "parent_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.partner"
      },
      "credentials": {
        "odooApi": {
          "id": "rhW7JbaWT0NTawBZ",
          "name": "IMM Odoo 18"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d55b9d2-a30b-4efd-8a22-e4d80851163a",
      "name": "Note d'aperçu2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 452,
        "height": 380,
        "content": "## Request & Validation\nReceives the API request and checks for the required “name” parameter.\nReturns a validation message if missing."
      },
      "typeVersion": 1
    },
    {
      "id": "e8d5c637-2adc-4c45-ab56-81eabe9af5ee",
      "name": "Note d'aperçu3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Search Records from Odoo\n- Queries `res.partner` \n**Contact 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": "5b009e21-3259-430b-aaf1-044e5c364eb8",
      "name": "Note d'aperçu4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Prepare data and manage response json object."
      },
      "typeVersion": 1
    },
    {
      "id": "af201ab6-7f0f-4806-bba1-7d9f718eeb75",
      "name": "Note d'aperçu5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Check response_format\nIf response_format=excel → returns a downloadable Excel file.\nOtherwise, returns JSON with company data."
      },
      "typeVersion": 1
    },
    {
      "id": "1b71d124-7d74-421c-882d-c67b6e6f9c08",
      "name": "Retourner toutes les données pour créer un fichier binaire",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        3104
      ],
      "parameters": {
        "jsCode": "return $input.all()"
      },
      "typeVersion": 2
    },
    {
      "id": "4dab4b62-287e-48ab-851d-8f8277d4eb10",
      "name": "Note d'aperçu6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Prepare Data for Binary file."
      },
      "typeVersion": 1
    },
    {
      "id": "d7dccf04-2209-4638-a535-175b8207a70d",
      "name": "Note d'aperçu7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Create excel file"
      },
      "typeVersion": 1
    },
    {
      "id": "278e9a77-f740-4adb-8a9b-465cc48b56e2",
      "name": "Note d'aperçu8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        2928
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Response to web-hook with excel file."
      },
      "typeVersion": 1
    },
    {
      "id": "e86f38f1-12de-4da2-99e2-f5e4cf863b27",
      "name": "Note d'aperçu9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        3328
      ],
      "parameters": {
        "color": 7,
        "width": 276,
        "height": 380,
        "content": "## Response to web-hook with json object."
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "ad743706-da44-436c-a330-96f289469989": {
      "main": [
        [
          {
            "node": "e727d97c-678b-41b8-8db4-d1615c73a116",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ed6030ad-11f0-43f6-aee5-147ee0c055de": {
      "main": [
        [
          {
            "node": "0e6e1540-4c2e-45fe-a75a-6e511a95937b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e727d97c-678b-41b8-8db4-d1615c73a116": {
      "main": [
        [
          {
            "node": "9187426f-d4d0-4461-af73-3f31cdb0cc17",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "66762aac-2d62-4d59-9956-816476d0f92f": {
      "main": [
        [
          {
            "node": "ad743706-da44-436c-a330-96f289469989",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9187426f-d4d0-4461-af73-3f31cdb0cc17": {
      "main": [
        [
          {
            "node": "1b71d124-7d74-421c-882d-c67b6e6f9c08",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d64e68cf-c80c-4633-bc4f-614d572ca762",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "752a1ab6-274c-4f09-9bf1-e2dba414aaf1": {
      "main": [
        [
          {
            "node": "66762aac-2d62-4d59-9956-816476d0f92f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1b71d124-7d74-421c-882d-c67b6e6f9c08": {
      "main": [
        [
          {
            "node": "ed6030ad-11f0-43f6-aee5-147ee0c055de",
            "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