PHPackages                             josespinal/odoo-rpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. josespinal/odoo-rpc

ActiveLibrary[API Development](/categories/api)

josespinal/odoo-rpc
===================

PHP Odoo RPC connector with JSON-RPC and XML-RPC support, prepared for Laravel integration

v9.1.4(1y ago)0193↑100%MITPHPPHP ^8.0

Since Jul 14Pushed 1y agoCompare

[ Source](https://github.com/josespinal/odoo-rpc)[ Packagist](https://packagist.org/packages/josespinal/odoo-rpc)[ Docs](https://github.com/josespinal/odoo-rpc)[ RSS](/packages/josespinal-odoo-rpc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (23)Used By (0)

Access Odoo via JSON-RPC and XML-RPC
====================================

[](#access-odoo-via-json-rpc-and-xml-rpc)

> **Note**: This package is a fork of [obuchmann/odoo-jsonrpc](https://github.com/obuchmann/odoo-jsonrpc) with several improvements:
>
> - Added XML-RPC support alongside JSON-RPC
> - Enhanced Laravel integration with proper service provider
> - Added Laravel Collection support for search results
> - Improved type safety and error handling
> - Added convenient methods like `first()` for better developer experience
> - Better PHP 8.0+ support

Connect to odoo via the json-rpc or xml-rpc api. If you are in a laravel project, this package registers a provider. But laravel is not required for this package.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require josespinal/odoo-rpc
```

The service provider will automatically register itself if you are in a laravel project.

You can publish the config file with:

```
php artisan vendor:publish --provider="JoseSpinal\OdooRpc\OdooServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Protocol Selection

[](#protocol-selection)

This package supports both JSON-RPC and XML-RPC protocols. You can specify which protocol to use in your configuration:

```
// In your .env file
ODOO_PROTOCOL=json-rpc  # or xml-rpc

// Or in your code
$config = new Config(
    database: 'odoo',
    host: 'http://localhost:8069',
    username: 'admin',
    password: 'password',
    protocol: 'xml-rpc'  // or 'json-rpc'
);
```

### Basic Usage

[](#basic-usage)

```
use JoseSpinal\OdooRpc\Odoo;
use JoseSpinal\OdooRpc\Odoo\Request\Arguments\Domain;

$this->host = 'http://localhost:8069';
$this->username = 'admin';
$this->password = 'password';
$this->database = 'odoo';

// Connect to Odoo
$odoo = new Odoo(new Odoo\Config($database, $host, $username, $password));
$odoo->connect();

// Check Access rights (bool)
$check = $odoo->checkAccessRights('res.partner', 'read');

// Check Access rights in model syntax

$check = $odoo->model('res.partner')
            ->can('read');

// Use Domain for Search
$isCompanyDomain = (new Domain())->where('is_company', '=', true);
$companyIds = $odoo->search('res.partner', $isCompanyDomain);

// read ids
$companies = $odoo->read('res.partner', $companyIds);

// search_read with model Syntax
$companies = $odoo->model('res.partner')
            ->where('is_company', '=', true)
            ->get();

// search_read with single item
$company = $odoo->model('res.partner')
            ->where('is_company', '=', true)
            ->where('name', '=', 'My Company')
            ->first();

// create with model syntax
$partner = $odoo->model('res.partner')
            ->create([
                'name' => 'My Company',
                'is_company' => true
            ]);

// update with model syntax
$partner = $odoo->model('res.partner')
            ->where('name', '=', 'My Company')
            ->update([
                'name' => 'My New Company'
            ]);
// direct update by id
$myCompanyId = 1;
$partner = $odoo->updateById('res.partner', $myCompanyId, [
    'name' => 'My New Company'
]);

// delete by id
$odoo->deleteById('res.partner', $myCompanyId);
```

### Laravel Usage

[](#laravel-usage)

```
class Controller{

    public function index(\JoseSpinal\OdooRpc\Odoo $odoo){
        // Find Model by Id
        $product = $odoo->find('product.template', 1);

        // Update Model by ID
        $this->odoo->updateById('product.product', $product->id, [
            'name' => $name,
        ]);

        // Create returning ID
        $id = $this->odoo
            ->create('res.partner', [
                'name' => 'Bobby Brown'
            ]);

        // Search for Models with or
        $partners = $this->odoo->model('res.partner')
            ->where('name', '=', 'Bobby Brown')
            ->orWhere('name', '=', 'Gregor Green')
            ->limit(5)
            ->orderBy('id', 'desc')
            ->get();

        // Update by Query
        $updateResponse = $this->odoo
            ->model('res.partner')
            ->where('name', '=', 'Bobby Brown')
            ->update([
                'name' => 'Dagobert Duck'
            ]);
    }
}
```

### Laravel Models

[](#laravel-models)

Laravel Models are implemented with Attributes

```
#[Model('res.partner')]
use JoseSpinal\OdooRpc\Odoo\OdooModel;

class Partner extends OdooModel
{
    #[Field]
    public string $name;

    #[Field('email')]
    public ?string $email;
}

class Controller{

    public function index(){
        // Find Model by Id
        $partner = Partner::find(1);

        // Search Model
        $partner = Partner::query()
            ->where('name', '=', 'Azure Interior')
            ->first();

        // Update Model
        $partner->name = "Dagobert Duck";
        $partner->save();

        // Create returning ID
        $partner = new Partner();
        $partner->name = 'Tester';
        $partner->save();
    }
}
```

### Casts

[](#casts)

You can define a cast for your models. This is useful if you want to convert odoo fields to a specific type. There are some predefined casts for date and datetime fields.

Casts are global and can be registered in the Odoo class.

```
// The basic datetime cast
\JoseSpinal\OdooRpc\Odoo::registerCast(new Odoo\Casts\DateTimeCast());

// a datetime cast that respects the timezone
\JoseSpinal\OdooRpc\Odoo::registerCast(new Odoo\Casts\DateTimeCast('Europe/Berlin'));

// you can write custom casts by extending the Obuchmann\OdooJsonRpc\Odoo\Casts\Cast class
// example DateTimeCast

class DateTimeCast extends Cast
{

    public function getType(): string
    {
        return \DateTime::class;
    }

    public function cast($raw)
    {
        if($raw){
            try {
                return new \DateTime($raw);
            } catch (\Exception) {} // If no valid Date return null
        }
        return null;
    }

    public function uncast($value)
    {
        if($value instanceof \DateTime){
            return $value->format('Y-m-d H:i:s');
        }
    }
}

```

For more examples take a look at the tests directory.

Tests
-----

[](#tests)

```
composer test
```

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance50

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~17 days

Total

22

Last Release

381d ago

Major Versions

v1.7.2 → v8.0.02025-02-13

v8.0.0 → v9.0.02025-02-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10059?v=4)[Jose Espinal](/maintainers/josespinal)[@josespinal](https://github.com/josespinal)

---

Top Contributors

[![obuchmann](https://avatars.githubusercontent.com/u/3889302?v=4)](https://github.com/obuchmann "obuchmann (39 commits)")[![josespinal](https://avatars.githubusercontent.com/u/10059?v=4)](https://github.com/josespinal "josespinal (28 commits)")[![xewl](https://avatars.githubusercontent.com/u/245041?v=4)](https://github.com/xewl "xewl (6 commits)")[![vheins](https://avatars.githubusercontent.com/u/20860294?v=4)](https://github.com/vheins "vheins (4 commits)")[![Zeeshansaaab](https://avatars.githubusercontent.com/u/73499389?v=4)](https://github.com/Zeeshansaaab "Zeeshansaaab (2 commits)")[![zgramming](https://avatars.githubusercontent.com/u/38829404?v=4)](https://github.com/zgramming "zgramming (2 commits)")

---

Tags

phplaraveljsonrpcodooxmlrpcERP

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/josespinal-odoo-rpc/health.svg)

```
[![Health](https://phpackages.com/badges/josespinal-odoo-rpc/health.svg)](https://phpackages.com/packages/josespinal-odoo-rpc)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[edujugon/laradoo

Odoo ERP API for Laravel

16468.6k](/packages/edujugon-laradoo)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[obuchmann/odoo-jsonrpc

PHP Odoo Json-RPC connector, prepared for laravel integration

6042.8k1](/packages/obuchmann-odoo-jsonrpc)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
