Download the PHP package flux-se/odoo-api-client without Composer
On this page you can find all versions of the php package flux-se/odoo-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package odoo-api-client
Odoo API client
Odoo (formerly OpenERP) is a Belgian suite of business management software tools (PGI) : https://www.odoo.com/.
This library allow communication trough Odoo JSON-RPC or XML-RPC API. Documentation about it can be found here (for the XML-RPC one, none for the JSON-RPC) : https://www.odoo.com/documentation/master/developer/reference/external_api.html
This library will allow you to :
- Generate PHP model classes based on the info available into your own Odoo database to ease your calls to the API
- Send requests to your Odoo instance through the JSON-RPC or the XML-RPC API
- Make raw requests like Ripcord was doing it but using newer libs like :
php-http/httplug
to make http requestssymfony/serializer
to handle the JSON/XML-RPC format and to transform resulting array to dedicated object classes.
Installation
Composer
Install using Composer :
php-http/guzzle7-adapter
andhttp-interop/http-factory-guzzle
are 2 requirements which can be chosen among php-http/client-implementation and psr/http-factory-implementation
Object models generation
First gather required credential and database info described here.
Depending on your Odoo instance the object models available will be different, that's why this library is allowing you to generate model classes using this cli command :
This command is using env vars to guess the credentials and database info, you can use those env vars to set your credential globally :
ODOO_API_HOST
ODOO_API_DATABASE
ODOO_API_USERNAME
ODOO_API_PASSWORD
Introduction
This chapter will describe how the two Odoo APIs are working.
JSON-RPC (Click me to see detailed info)
### JSON-RPC The Odoo JSON-RPC API expose 1 main endpoint `/jsonrpc`. The body request payload is a JSON object with specific data into it : The service param can be set with those 3 values : - `db` allowing to manage the postgres database - `common` allowing to authenticate a user or get info about the Odoo installation - `object` allowing operations with all API exposed models This library help you to use those endpoints using `ext-json` and `HttPlug`, **it also allows you to consume Odoo API using PHP classes representation of all installed Odoo Models**.XML-RPC (Click me to see detailed info)
### XML-RPC The Odoo XML-RPC API expose 3 main endpoints : - `/xmlrpc/2/db` allowing to manage the postgres database - `/xmlrpc/2/common` allowing to authenticate a user or get info about the Odoo installation - `/xmlrpc/2/object` allowing operations with all API exposed models This library help you to use those endpoints using `ext-xmlrpc` and `HttPlug`, **it also allows you to consume Odoo API using PHP classes representation of all installed Odoo Models**. The authentication is not standard (compare to other APIs), your username and your password will be used during a call to `/xmlrpc/2/common` with the XML-RPC method `authenticate` (or `login`) returning your Odoo user id (`uid`). This uid, your password and your Odoo database name are required to make every request calls to the `/xmlrpc/2/object` endpoint.Usage example
Using this library you will be able to use two ways of consuming the Odoo XML-RPC API :
- using array
- using object model classes
Using Array
List your first partner (Contact) :
By default, the JSON-RPC API will be used, if you want to use XML-RPC create an Odoo Api Client builder like this :
Using object model
First you can generate classes based on the Odoo instance you have, for example:
💡 Here we are generating only one class, but you can also generate all classes excluding some of them (see info here).
Know issues
- Since Odoo v16 some new fields can produce 500 errors, I try to create issues about them when I get the error, you can found the relates issues here : https://github.com/odoo/odoo/issues?q=is%3Aissue+author%3APrometee+
Development
Using docker
The server is fully ready to use when this log line appears (Odoo v13 could take longer than upper version to reach this line) :
Generate the model classes based on the docker Odoo instance :
This script will use env vars to gather info about the Odoo instance you are targeting (see info here).
Test the code against the generated classes from your own Odoo instance
`
All versions of odoo-api-client with dependencies
php-http/client-implementation Version ^1.0
php-http/client-common Version ^2.1
php-http/discovery Version ^1.7
psr/http-factory-implementation Version ^1.0
symfony/console Version ^6.4|^7.1
symfony/serializer Version ^6.4|^7.1
symfony/property-access Version ^6.4|^7.1
symfony/property-info Version ^6.4|^7.1
symfony/string Version ^6.4|^7.1
symfony/http-kernel Version ^6.4|^7.1
php-http/logger-plugin Version ^1.1
phpdocumentor/reflection-docblock Version ^5.4
prometee/php-class-generator Version ^1.0
webmozart/assert Version ^1