Exportar datos de la empresa de Odoo a través del punto final de la API, con opciones de salida JSON/Excel

Avanzado

Este es unCRMflujo de automatización del dominio deautomatización que contiene 18 nodos.Utiliza principalmente nodos como If, Code, Odoo, Webhook, Function. Exportar datos de empresas de Odoo a través de puntos finales de API, con opciones de salida JSON/Excel

Requisitos previos
  • Punto final de HTTP Webhook (n8n generará automáticamente)

Categoría

Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "6b3e8c6c30cdfbf06283a3fa57016932c6b4ec959896c5c546ef5865ff697ff1"
  },
  "nodes": [
    {
      "id": "2b167f16-af65-4d8f-9a83-3dff9c06f99c",
      "name": "Recibir Solicitud de Empresa",
      "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": "Preparar Filtro Dinámico",
      "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": "Obtener Empresas desde 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": "Preparar Datos de Salida",
      "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": "Verificar si se Requiere Excel",
      "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 a Excel",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1104,
        1376
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1.1
    },
    {
      "id": "38164711-9c8c-4f7c-8e3b-3f19b1c12360",
      "name": "Responder con Archivo",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1392,
        1376
      ],
      "parameters": {
        "options": {},
        "respondWith": "binary"
      },
      "typeVersion": 1.4
    },
    {
      "id": "cba096d5-0e19-4bec-930e-eefe587e996e",
      "name": "Responder con JSON",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        784,
        1776
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.4
    },
    {
      "id": "5f3f46b8-330a-4594-8170-6b2e8d68b685",
      "name": "Nota de Visión General",
      "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": "Código",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        1392
      ],
      "parameters": {
        "jsCode": "return $input.all()"
      },
      "typeVersion": 2
    },
    {
      "id": "d29068b1-e243-420b-b00c-24f9ecaa0512",
      "name": "Nota de Visión General10",
      "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": "Nota de Visión General11",
      "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": "Nota de Visión General12",
      "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": "Nota de Visión General13",
      "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": "Nota de Visión General14",
      "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": "Nota de Visión General15",
      "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": "Nota de Visión General16",
      "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": "Nota de Visión General17",
      "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
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - CRM

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos18
Categoría1
Tipos de nodos8
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
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.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34