spejder / odoo-client
A PHP Client for Odoo
Installs: 7 720
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.1
- laminas/laminas-http: ^2.12
- laminas/laminas-xmlrpc: ^2.9
Requires (Dev)
Replaces
- jacobsteringa/odoo-client: <=0.3.0
- dev-master
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2024-10-24 06:24:28 UTC
README
OdooClient is an Odoo client for PHP. It is inspired on OpenERP API from simbigo and uses a more or less similar API. Instead of an own XML-RPC client it depends on the XML-RPC and XML libraries from Laminas (formerly Zend Framework).
ℹ️ This is a fork of the inactive jacobsteringa/odoo-client. Dependencies have been updated and code style modernized to PSR-12. Actual credit for the code goes to @jacobsteringa ❤️
Supported versions
This library should work with Odoo 8 and 9. If you find any any incompatibilities, please create an issue or submit a pull request.
Known issues
- The
Odoo::getReport()
method in v0.2.2 and lower does not work with Odoo 9.
Usage
Instantiate a new client.
use Spejder\Odoo\Odoo; $url = 'example.odoo.com/xmlrpc/2'; $database = 'example-database'; $user = 'user@email.com'; $password = 'yourpassword'; $client = new Odoo($url, $database, $user, $password);
For the client to work you have to include the /xmlrpc/2
part of the
url.
When you need to tweak the HTTP client used by the XML-RPC client, you
can inject a custom HTTP client via the constructor or the
Odoo::setHttpClient
method.
use Spejder\Odoo\Odoo; use Laminas\Http\Client as HttpClient; $httpClient = new HttpClient(null, [ 'sslverifypeer' => false, ]); // constructor argument $client = new Odoo($url, $database, $user, $password, $httpClient); // or setter $client = new Odoo($url, $database, $user, $password); $client->setHttpClient($httpClient);
xmlrpc/2/common endpoint
Getting version information.
$client->version();
Getting timezone information.
$client->timezone();
There is no login/authenticate method. The client does authentication for you, that is why the credentials are passed as constructor arguments.
xmlrpc/2/object endpoint
Search for records.
$criteria = [ ['customer', '=', true], ]; $limit = 10; $offset = 0; $client->search('res.partner', $criteria, $offset, $limit);
Reading records.
$ids = $client->search('res.partner', [['customer', '=', true]], 0, 10); $fields = ['name', 'email', 'customer']; $customers = $client->read('res.partner', $ids, $fields);
Creating records.
$data = [ 'name' => 'John Doe', 'email' => 'foo@bar.com', ]; $id = $client->create('res.partner', $data);
Updating records.
// change email address of user with current email address foo@bar.com $ids = $client->search('res.partner', [['email', '=', 'foo@bar.com']], 0, 1); $client->write('res.partner', $ids, ['email' => 'baz@quux.com']); // 'uncustomer' the first 10 customers $ids = $client->search('res.partner', [['customer', '=', true]], 0, 10); $client->write('res.partner', $ids, ['customer' => false]);
Deleting records.
$ids = $client->search('res.partner', [['email', '=', 'baz@quuz.com']], 0, 1); $client->unlink('res.partner', $ids);
Get report in base64 format.
$ids = $client->search('res.partner', [['customer', '=', true]], 0, 10); $report = $client->getReport('res.partner', $ids);
License
MIT License. Copyright (c) 2014 Jacob Steringa.