alazzi-az/laraodoo-xmlrpc 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

alazzi-az/laraodoo-xmlrpc

Composer 安装命令:

composer require alazzi-az/laraodoo-xmlrpc

包简介

Odoo-Xmlrpc PHP for Laravel is a supercharged PHP API client that allows you to interact with the Odoo XML-RPC API

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

The Odoo XML-RPC Client is a PHP package that provides a simple and easy-to-use interface for interacting with the Odoo XML-RPC API. Unlike other Odoo clients that require extensions or other dependencies, this client uses the laminas/laminas-xmlrpc package, which is a pure PHP implementation of the XML-RPC protocol.

Requirements

  • PHP 8.1 or later

Get Started

First, install laraodoo-xmlrpc via the Composer package manager:

composer require alazzi-az/laraodoo-xmlrpc

Next, publish the configuration file:

php artisan vendor:publish --provider="Alazzidev\LaraodooXmlrpc\ServiceProvider"

This will create a config/odoo-xmlrpc..php configuration file in your project, which you can modify to your needs using environment variables:

return [
    'url' => env('ODOO_URL', ''),
    'suffix' => 'xmlrpc/2',
    'db' => env('ODOO_DB', ''),
    'username' => env('ODOO_USERNAME', ''),
    'password' => env('ODOO_PASSWORD', ''),
];

Finally, you may use the Odoo facade to access the Odoo Xml API:

use Alazzidev\LaraodooXmlrpc\Facades\Odoo;

$result = Odoo::model('res.partner')->create([
            'test1'=>'test1-value',
            'test2'=>'test2-value'
            ]);

Usage

For usage examples, take a look at the alazzi-az/odoo-xmlrpc repository.

Use Case

For Create Invoice in Cummonity Version "account.move"

use Alazzidev\LaraodooXmlrpc\Facades\Odoo;

// Define invoice line
$line = [
    0,
    false,
    [
        'currency_id' => $currency_id,
        'discount' => $discountPercentage,
        'display_type' => 'product',
        'name' => $name,
        'price_unit' => $price_unit,
        'product_id' => $product_id,
        'quantity' => $quantity,
        'tax_ids' => $tax_ids,
    ]
];

$invoice_lines = [$line];

// Define invoice data
$invoice = [
    'partner_id' => $partner_id,
    'name' => $name,
    'invoice_date' => $invoice_date,
    'invoice_date_due' => $invoice_date_due,
    'payment_reference' => $payment_reference,
    'invoice_line_ids' => $invoice_lines,
    'currency_id' => $currency_id,
    'invoice_payment_term_id' => $payment_term_id,
    'state' => $state,
    'journal_id' => $journal_id,
    'move_type' => 'out_invoice',
];

// Create invoice using Odoo External API
$odoo = Odoo::model('account.move');
$odoo_invoice_id = $odoo->create($invoice);

Testing

The Odoo facade comes with a fake() method that allows you to fake the API responses.

The fake responses are returned in the order they are provided to the fake() method.

All responses are having a fake() method that allows you to easily create a response object by only providing the parameters relevant for your test case.

use Alazzidev\LaraodooXmlrpc\Facades\Odoo;

  Odoo::fake([
        'test1'=>'test1-value',
        'test2'=>'test2-value'
    ]);

    $response = Odoo::create('res.partner',[
        'test1'=>'test1-value',
        'test2'=>'test2-value'
    ]);

    expect($response['test1'])->toBe('test1-value');

And here You Can run test

composer test:unit

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 8.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固