Skip to content

akr-odoo/odoo-js-xmlrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Odoo XML-RPC Client

Simple JavaScript client for connecting to Odoo via XML-RPC calls.

📁 Files

  • odoo-rpc-client.js - Core library (the engine)
  • odoo-rpc-examples.js - Usage examples and demos
  • README.md - This file

🚀 How to Run

Option 1: Browser Console (Easiest for Testing)

  1. Open your browser's developer tools (F12)
  2. Go to the Console tab
  3. Copy and paste the contents of odoo-rpc-client.js first
  4. Then copy and paste the contents of odoo-rpc-examples.js
  5. Press Enter and watch it run!

Option 2: HTML File (Best for Web Apps)

Create an HTML file:

<!DOCTYPE html>
<html>
<head>
    <title>Odoo RPC Client</title>
</head>
<body>
    <h1>Odoo RPC Client</h1>
    <p>Check the browser console for output!</p>
    
    <script src="odoo-rpc-client.js"></script>
    <script src="odoo-rpc-examples.js"></script>
</body>
</html>

Then open the HTML file in your browser.

Option 3: Node.js (For Server-Side)

Requirements: Node.js 18+ (for built-in fetch support)

# If you have Node.js 18+
node odoo-rpc-examples.js

# Or if you need to combine both files
cat odoo-rpc-client.js odoo-rpc-examples.js > combined.js
node combined.js

For older Node.js versions, install a fetch polyfill:

npm install node-fetch

Then add this line at the top of odoo-rpc-client.js:

import fetch from 'node-fetch';

Option 4: Deno (Modern Runtime)

deno run --allow-net odoo-rpc-examples.js

⚙️ Configuration

Before running, update these settings in odoo-rpc-examples.js:

const rpc_client = new RPCClient({ 
    baseURL: "YOUR_ODOO_URL_HERE" 
});

await rpc_client.login({
    db: "YOUR_DATABASE_NAME",
    login: "YOUR_USERNAME",
    password: "YOUR_PASSWORD"
});

🔧 Quick Start

  1. Include the library:

    // In browser or add <script> tag
    const client = new RPCClient({ baseURL: "https://your-odoo.com" });
  2. Login:

    await client.login({
        db: "your-db",
        login: "your-email",
        password: "your-password"
    });
  3. Make calls:

    const partners = await client.call({
        model: "res.partner",
        method: "search_read",
        args: [[]], // empty domain = get all
        kwargs: { fields: ["name", "email"], limit: 10 }
    });

🛠️ Common Issues

CORS Errors: If running from a browser, your Odoo instance needs to allow CORS from your domain.

Authentication: Make sure your Odoo user has the right permissions for the operations you're trying to perform.

Network: Ensure your Odoo instance is accessible from where you're running the code.

📖 More Examples

Check odoo-rpc-examples.js for complete examples including:

  • Reading data (search, search_read)
  • Creating records (partners, products, invoices)
  • Updating records
  • Deleting records
  • Complex workflows

🔗 Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published