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

You Asked,
We made it!

fix japanese keyword hack

Step by Step Video Tutorials on trending topics in software development

Yes I am Curious »

AR in Websites – Top 3 Platforms for Bringing Augmented Reality to Your Web Experience

As technology advances, augmented reality (AR) is no longer limited to gaming or social media apps. Integrating AR into websites...

Know More »

Webhook Explained for Beginners: Everything You Need to Know

In the world of APIs, automation, and modern web applications, the term “webhook” often comes up. But what exactly is...

Know More »