[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-a1c203ff-b5b9-4e66-b1af-b94fd8ee4bb7":3,"$fv1onDSme_fIwMTPMtuVIes-riROWlagketcwdh_mxHk":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"a1c203ff-b5b9-4e66-b1af-b94fd8ee4bb7","odoo-rpc-api","Odoo的外部JSON-RPC和XML-RPC API专家。涵盖认证、模型调用、记录CRUD以及Python、JavaScript和curl中的实际集成示例。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: odoo-rpc-api\ndescription: \"Expert on Odoo's external JSON-RPC and XML-RPC APIs. Covers authentication, model calls, record CRUD, and real-world integration examples in Python, JavaScript, and curl.\"\nrisk: safe\nsource: \"self\"\n---\n\n# Odoo RPC API\n\n## Overview\n\nOdoo exposes a powerful external API via JSON-RPC and XML-RPC, allowing any external application to read, create, update, and delete records. This skill guides you through authenticating, calling models, and building robust integrations.\n\n## When to Use This Skill\n\n- Connecting an external app (e.g., Django, Node.js, a mobile app) to Odoo.\n- Running automated scripts to import\u002Fexport data from Odoo.\n- Building a middleware layer between Odoo and a third-party platform.\n- Debugging API authentication or permission errors.\n\n## How It Works\n\n1. **Activate**: Mention `@odoo-rpc-api` and describe the integration you need.\n2. **Generate**: Get copy-paste ready RPC call code in Python, JavaScript, or curl.\n3. **Debug**: Paste an error and get a diagnosis with a corrected call.\n\n## Examples\n\n### Example 1: Authenticate and Read Records (Python)\n\n```python\nimport xmlrpc.client\n\nurl = 'https:\u002F\u002Fmyodoo.example.com'\ndb = 'my_database'\nusername = 'admin'\npassword = 'my_api_key'  # Use API keys, not passwords, in production\n\n# Step 1: Authenticate\ncommon = xmlrpc.client.ServerProxy(f'{url}\u002Fxmlrpc\u002F2\u002Fcommon')\nuid = common.authenticate(db, username, password, {})\nprint(f\"Authenticated as UID: {uid}\")\n\n# Step 2: Call models\nmodels = xmlrpc.client.ServerProxy(f'{url}\u002Fxmlrpc\u002F2\u002Fobject')\n\n# Search confirmed sale orders\norders = models.execute_kw(db, uid, password,\n    'sale.order', 'search_read',\n    [[['state', '=', 'sale']]],\n    {'fields': ['name', 'partner_id', 'amount_total'], 'limit': 10}\n)\nfor order in orders:\n    print(order)\n```\n\n### Example 2: Create a Record (Python)\n\n```python\nnew_partner_id = models.execute_kw(db, uid, password,\n    'res.partner', 'create',\n    [{'name': 'Acme Corp', 'email': 'info@acme.com', 'is_company': True}]\n)\nprint(f\"Created partner ID: {new_partner_id}\")\n```\n\n### Example 3: JSON-RPC via curl\n\n```bash\ncurl -X POST https:\u002F\u002Fmyodoo.example.com\u002Fweb\u002Fdataset\u002Fcall_kw \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"call\",\n    \"id\": 1,\n    \"params\": {\n      \"model\": \"res.partner\",\n      \"method\": \"search_read\",\n      \"args\": [[[\"is_company\", \"=\", true]]],\n      \"kwargs\": {\"fields\": [\"name\", \"email\"], \"limit\": 5}\n    }\n  }'\n# Note: \"id\" is required by the JSON-RPC 2.0 spec to correlate responses.\n# Odoo 16+ also supports the \u002Fweb\u002Fdataset\u002Fcall_kw endpoint but\n# prefer \u002Fweb\u002Fdataset\u002Fcall_kw for model method calls.\n```\n\n## Best Practices\n\n- ✅ **Do:** Use **API Keys** (Settings → Technical → API Keys) instead of passwords — available from Odoo 14+.\n- ✅ **Do:** Use `search_read` instead of `search` + `read` to reduce network round trips.\n- ✅ **Do:** Always handle connection errors and implement retry logic with exponential backoff in production.\n- ✅ **Do:** Store credentials in environment variables or a secrets manager (e.g., AWS Secrets Manager, `.env` file).\n- ❌ **Don't:** Hardcode passwords or API keys directly in scripts — rotate them and use env vars.\n- ❌ **Don't:** Call the API in a tight loop without batching — bulk operations reduce server load significantly.\n- ❌ **Don't:** Use the master admin password for API integrations — create a dedicated integration user with minimum required permissions.\n\n## Limitations\n\n- Does not cover **OAuth2 or session-cookie-based authentication** — the examples use API key (token) auth only.\n- **Rate limiting** is not built into the Odoo XMLRPC layer; you must implement throttling client-side.\n- The XML-RPC endpoint (`\u002Fxmlrpc\u002F2\u002F`) does not support file uploads — use the REST-based `ir.attachment` model via JSON-RPC for binary data.\n- Odoo.sh (SaaS) may block some API calls depending on plan; verify your subscription supports external API access.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,74,958,"2026-05-16 13:32:25",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"b7629113-5a75-459d-9b13-77b9198d7780","1.0.0","odoo-rpc-api.zip",2060,"uploads\u002Fskills\u002Fa1c203ff-b5b9-4e66-b1af-b94fd8ee4bb7\u002Fodoo-rpc-api.zip","ab7e375dca91cdfd74db5743a642281bee34c0ebdbacd2792a5b54ca79a6720d","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":3988}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]