Odooの顧客データを取得し、JSONまたはExcel形式でエクスポート

上級

これはCRM分野の自動化ワークフローで、18個のノードを含みます。主にIf, Code, Odoo, Webhook, Functionなどのノードを使用。 Odoo顧客データを取得し、JSONまたはExcel形式でエクスポート

前提条件
  • HTTP Webhookエンドポイント(n8nが自動生成)

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "6b3e8c6c30cdfbf06283a3fa57016932c6b4ec959896c5c546ef5865ff697ff1"
  },
  "nodes": [
    {
      "id": "752a1ab6-274c-4f09-9bf1-e2dba414aaf1",
      "name": "Receive Company Request1",
      "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": "Prepare Dynamic フィルター1",
      "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": "Prepare Output Data1",
      "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": "Check If Excel Required1",
      "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": "Convert to Excel1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        896,
        3104
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0e6e1540-4c2e-45fe-a75a-6e511a95937b",
      "name": "Respond with File1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        3104
      ],
      "parameters": {
        "options": {},
        "respondWith": "binary"
      },
      "typeVersion": 1.4
    },
    {
      "id": "d64e68cf-c80c-4633-bc4f-614d572ca762",
      "name": "Respond with JSON1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        3504
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.4
    },
    {
      "id": "d2f28f28-a541-42d1-aaf8-94ab14723a53",
      "name": "Overview ノート1",
      "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": "Fetch Customer",
      "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": "Overview ノート2",
      "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": "Overview ノート3",
      "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": "Overview ノート4",
      "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": "Overview ノート5",
      "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": "Return all data for create binary file",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        3104
      ],
      "parameters": {
        "jsCode": "return $input.all()"
      },
      "typeVersion": 2
    },
    {
      "id": "4dab4b62-287e-48ab-851d-8f8277d4eb10",
      "name": "Overview ノート6",
      "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": "Overview ノート7",
      "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": "Overview ノート8",
      "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": "Overview ノート9",
      "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
          }
        ]
      ]
    },
    "Prepare Dynamic Filter1": {
      "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": "Prepare Dynamic Filter1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1b71d124-7d74-421c-882d-c67b6e6f9c08": {
      "main": [
        [
          {
            "node": "ed6030ad-11f0-43f6-aee5-147ee0c055de",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - 顧客管理

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数18
カテゴリー1
ノードタイプ8
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
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.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34