定制 obuchmann/laravel-odoo-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

obuchmann/laravel-odoo-api

Composer 安装命令:

composer require obuchmann/laravel-odoo-api

包简介

Laravel connector for Odoo

README 文档

README

This is a medium level API to Odoo (former OpenERP) XMLRPC-API for Laravel. Odoo website

This package is a successor of Laradoo, but there is no backwards compatibility!

⚠️ This Package is not Maintained any more. Successor is Odoo Jsonrpc

Compatibility

Laravel 7 and higher

Odoo 8.0 and higher

Php 7.4 and higher

Installation

This package is installed via Composer. To install, run the following command.

composer require obuchmann/laravel-odoo-api

Publish the package's configuration file to the application's own config directory

php artisan vendor:publish --provider="Obuchmann\LaravelOdooApi\Providers\OdooServiceProvider" --tag="config"

This package supports autodiscover.

If you don't use autodiscover for reasons, you can add the provider as described below.

Register Laravel Odoo Api service by adding it to the providers array.

'providers' => array(
        ...
        Obuchmann\LaravelOdooApi\Providers\OdooServiceProvider::class
    )

You can also add the Alias facade.

'aliases' => array(
        ...
        'Odoo' => Obuchmann\LaravelOdooApi\Facades\Odoo::class,
    )

Configuration

After publishing the package config file, the base configuration for laravel-odoo-api package is located in config/laravel-odoo-api.php

Also, you can dynamically update those values calling the available setter methods:

host($url), username($username), password($password), database($name), apiSuffix($name)

Usage samples

Instance the main Odoo class:

$odoo = new \Obuchmann\LaravelOdooApi\Odoo();

You can get the Odoo API version just calling the version method:

$version = $odoo->version();

This methods doesn't require to be connected/Logged into the ERP.

Connect and log into the ERP:

$odoo = $odoo->connect();

All needed configuration data is taken from laravel-odoo-api.php config file. But you always may pass new values on the fly if required.

$this->odoo = $this->odoo
            ->username('my-user-name')
            ->password('my-password')
            ->database('my-db')
            ->host('https://my-host.com')
            ->connect();

// Note: host should contain 'http://' or 'https://'

After login, you can check the user identifier like follows:

$userId = $this->odoo->getUid();

You always can check the permission on a specific model:

$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:

$ids = $odoo
    ->model('res.partner')
    ->where('customer', '=', true)
    ->search();

You can limit the amount of data using limit method and use as many as condition you need:

$ids = $odoo
    ->model('res.partner')
    ->where('is_company', true)
    ->where('customer', '=', true)
    ->limit(3)
    ->search();

If need to get a list of models, use the get method:

$models = $odoo
    ->model('res.partner')
    ->where('customer', true)
    ->limit(3)
    ->get();

Instead of retrieving all properties of the models, you can reduce it by adding fields method before the method get

$models = $odoo
    ->model('res.partner')
    ->where('customer', true)
    ->limit(3)
    ->fields(['name'])
    ->get();

If not sure about what fields a model has, you can retrieve the model structure data by calling fieldsOf method:

$structure = $odoo
    ->model('res.partner')
    ->listModelFields();

Till now we have only retrieved data from Odoo but you can also Create and Delete records.

In order to create a new record just call create method as follows:

$id = $odoo
    ->model('res.partner')
    ->create(['name' => 'Bobby Brown']);

The method returns the id of the new record.

For Deleting records we have the delete method:

$result = $odoo
    ->model('res.partner')
    ->where('name', '=', 'Bobby Brown')
    ->delete();

Notice that before calling delete method you have to use where.

You can also remove records by ids like follows:

$result = $odoo
    ->model('res.partner')
    ->deleteById($ids);

Update any record of your Odoo:

$updateSuccessfull = $odoo
    ->model('res.partner')
    ->where('name', '=', 'Bobby Brown')
    ->update(['name' => 'Dagobert Duck','email' => 'daduck@odoo.com']);

Notice that all delete and update methods always returns true except if there was an error.

Custom api Calls are also supported

$ids = $odoo
    ->model('res.partner')
    ->setMethod('search')
    ->setArguments([[
        ['is_company', '=', true]
    ]])
    ->setOption('limit', 3)
    ->addResponseClass(Odoo\Response\ListResponse::class)
    ->get();

obuchmann/laravel-odoo-api 适用场景与选型建议

obuchmann/laravel-odoo-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.58k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「laravel」 「odoo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 obuchmann/laravel-odoo-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 obuchmann/laravel-odoo-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 obuchmann/laravel-odoo-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 99
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-21