-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,20 @@ Odoo ERP API for Laravel. [Odoo website](https://www.odoo.com) | |
|
||
type in console: | ||
|
||
``` | ||
```shel | ||
composer require edujugon/laradoo | ||
``` | ||
|
||
Register Laradoo service by adding it to the providers array. | ||
``` | ||
```php | ||
'providers' => array( | ||
... | ||
Edujugon\Laradoo\Providers\OdooServiceProvider::class | ||
) | ||
``` | ||
|
||
Let's add the Alias facade, add it to the aliases array. | ||
``` | ||
```php | ||
'aliases' => array( | ||
... | ||
'Odoo' => Edujugon\Laradoo\Facades\Odoo::class, | ||
|
@@ -36,7 +36,7 @@ Let's add the Alias facade, add it to the aliases array. | |
|
||
Publish the package's configuration file to the application's own config directory | ||
|
||
``` | ||
```php | ||
php artisan vendor:publish --provider="Edujugon\Laradoo\Providers\OdooServiceProvider" --tag="config" | ||
``` | ||
|
||
|
@@ -54,58 +54,57 @@ Also, you can dynamically update those values calling the available setter metho | |
|
||
Instance the main Odoo class: | ||
|
||
``` | ||
```php | ||
$odoo = new \Edujugon\Laradoo\Odoo(); | ||
``` | ||
You can get the Odoo API version just calling the version method: | ||
|
||
``` | ||
```php | ||
$version = $odoo->version(); | ||
``` | ||
> This methods doesn't require to be connected/Logged into the ERP. | ||
Connect and log into the ERP: | ||
|
||
``` | ||
```php | ||
$odoo = $odoo->connect(); | ||
``` | ||
|
||
All needed configuration data is taken from `laradoo.php` config file. But you always may pass new values on the fly if required. | ||
|
||
``` | ||
```php | ||
$this->odoo = $this->odoo | ||
->username('my-user-name') | ||
->password('my-password) | ||
->password('my-password') | ||
->db('my-db') | ||
->host('https://my-host.com') | ||
->connect(); | ||
// Note: `host` should contain 'http://' or 'https://' | ||
``` | ||
|
||
> // Note: `host` should contain 'http://' or 'https://' | ||
After login, you can check the user identifier like follows: | ||
|
||
``` | ||
```php | ||
$userId= $this->odoo->getUid(); | ||
``` | ||
|
||
You always can check the permission on a specific model: | ||
|
||
``` | ||
```php | ||
$can = $odoo->can('read', 'res.partner'); | ||
``` | ||
> Permissions which can be checked: 'read','write','create','unlink' | ||
Method `search provides a collection of ids based on your conditions: | ||
|
||
``` | ||
```php | ||
$ids = $odoo->where('customer', '=', true) | ||
->search('res.partner'); | ||
``` | ||
|
||
You can limit the amount of data using `limit` method and use as many as condition you need: | ||
|
||
``` | ||
```php | ||
$ids = $odoo->where('is_company', true) | ||
->where('customer', '=', true) | ||
->limit(3) | ||
|
@@ -114,15 +113,15 @@ $ids = $odoo->where('is_company', true) | |
|
||
If need to get a list of models, use the `get` method: | ||
|
||
``` | ||
```php | ||
$models = $odoo->where('customer', true) | ||
->limit(3) | ||
->get('res.partner'); | ||
``` | ||
|
||
Instead of retrieving all properties of the models, you can reduce it by adding `fields` method before the method `get` | ||
|
||
``` | ||
```php | ||
$models = $odoo->where('customer', true) | ||
->limit(3) | ||
->fields('name') | ||
|
@@ -131,36 +130,36 @@ $models = $odoo->where('customer', true) | |
|
||
If not sure about what fields a model has, you can retrieve the model structure data by calling `fieldsOf` method: | ||
|
||
``` | ||
```php | ||
$structure = $odoo->fieldsOf('res.partner'); | ||
``` | ||
|
||
Till now we have only retrieved data from the ERP but you can also Create and Delete records. | ||
|
||
In order to create a new record just call `create` method as follows: | ||
|
||
``` | ||
```php | ||
$id = $odoo->create('res.partner',['name' => 'Jonh Odoo']); | ||
``` | ||
> The method returns the id of the new record. | ||
For Deleting records we have the `delete` method: | ||
|
||
``` | ||
```php | ||
$result = $odoo->where('name', 'Jonh Odoo') | ||
->delete('res.partner'); | ||
``` | ||
> Notice that before calling `delete` method you have to use `where`. | ||
You can also remove records by ids like follows: | ||
|
||
``` | ||
```php | ||
$result = $odoo->deleteById('res.partner',$ids); | ||
``` | ||
|
||
Update any record of your ERP: | ||
|
||
``` | ||
```php | ||
$updated = $odoo->where('name', 'John Odoo') | ||
->update('res.partner',['name' => 'John Odoo Odoo','email' => '[email protected]']); | ||
``` | ||
|
@@ -169,7 +168,7 @@ Notice that all `delete` and `update` methods always returns `true` except if th | |
|
||
`call` method is also available for those who want to set a custom API call: | ||
|
||
``` | ||
```php | ||
$odoo->call('res.partner', 'search',[ | ||
[ | ||
['is_company', '=', true], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters