Integrated Tech Solutions

How to use Odoo External Api in PHP > 8.0

By - Admin, Updated on February 19, 2024

What is odoo external api?

Just like every other software application, odoo itself also allows to perform certain actions programatically without entering the dashboard.

One of the most common problem developers are facing is removal of xml-rpc module from php versions above 8.0

To get it working, we’ll use the odoo-xmlrpc library

Installation

This library can be easily installed using the composer command below –

composer require alazzi-az/odoo-xmlrpc 
use AlazziAz\OdooXmlrpc\Client;

// Call a method on the Odoo server
$result = $client->call('res.partner', 'search_read', [], ['limit' => 5]);

// Get records from a model
$records = $client->get('res.partner', [], ['name', 'id'], 5);

// Search for records in a model
$searchResult = $client->search('res.partner', []);

// Read records from a model
$records = $client->read('res.partner', $searchResult, ['name', 'id']);

// Create a new record in a model
$id = $client->create('res.partner', [
    'name' => 'John Doe',
    'email' => 'johndoe@example.com'
]);

// Update an existing record in a model
$result = $client->update('res.partner', [$id], [
    'name' => 'Jane Doe',
    'email' => 'janedoe@example.com'
]);

// Delete a record from a model
$result = $client->delete('res.partner', [$id]);

// Get the number of records in a model
$count = $client->count('res.partner', []);

// Get the current user's ID
$uid = $client->getUid();

// Get the version of the Odoo server
$version = $client->getVersion();

Keep Reading

👋 Hi, Find this Helpful? There is More

20 Most asked Odoo Interview Questions

Odoo Accounting Interview Questions

Know More »
shopify sections and blocks

How to create Custom Sections in Shopify[Dawn Theme]

Are you looking to customize your Shopify store beyond the standard templates and themes? Do you want to create unique...

Know More »
fix japanese keyword hack

Looking for Video Tutorials?

Explore Our Youtube Channel for in-depth Tutorials

Yes I am Curious »