PHP code example of obuchmann / laravel-odoo-api
1. Go to this page and download the library: Download obuchmann/laravel-odoo-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
obuchmann / laravel-odoo-api example snippets
php artisan vendor:publish --provider="Obuchmann\LaravelOdooApi\Providers\OdooServiceProvider" --tag="config"
'providers' => array(
...
Obuchmann\LaravelOdooApi\Providers\OdooServiceProvider::class
)
'aliases' => array(
...
'Odoo' => Obuchmann\LaravelOdooApi\Facades\Odoo::class,
)
$odoo = new \Obuchmann\LaravelOdooApi\Odoo();
$version = $odoo->version();
$odoo = $odoo->connect();
$this->odoo = $this->odoo
->username('my-user-name')
->password('my-password')
->database('my-db')
->host('https://my-host.com')
->connect();
$userId = $this->odoo->getUid();
$can = $odoo->can('read', 'res.partner');
$ids = $odoo
->model('res.partner')
->where('customer', '=', true)
->search();
$ids = $odoo
->model('res.partner')
->where('is_company', true)
->where('customer', '=', true)
->limit(3)
->search();
$models = $odoo
->model('res.partner')
->where('customer', true)
->limit(3)
->get();
$models = $odoo
->model('res.partner')
->where('customer', true)
->limit(3)
->fields(['name'])
->get();
$structure = $odoo
->model('res.partner')
->listModelFields();
$id = $odoo
->model('res.partner')
->create(['name' => 'Bobby Brown']);
$result = $odoo
->model('res.partner')
->where('name', '=', 'Bobby Brown')
->delete();
$result = $odoo
->model('res.partner')
->deleteById($ids);
$updateSuccessfull = $odoo
->model('res.partner')
->where('name', '=', 'Bobby Brown')
->update(['name' => 'Dagobert Duck','email' => '[email protected] ']);
$ids = $odoo
->model('res.partner')
->setMethod('search')
->setArguments([[
['is_company', '=', true]
]])
->setOption('limit', 3)
->addResponseClass(Odoo\Response\ListResponse::class)
->get();