如何从PHP访问OPENERP方法?

时间:2012-02-14 09:49:36

标签: php xml-rpc openerp

我需要将开放的erp hr模块与php网站集成。为此,我尝试使用XML-RPC。 但我没有得到如何访问它的方法。我需要使用开放erp中的休假,时间表和工资计算。

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

您可以像访问其他CRUD方法一样访问openerp中的方法。 它没有在openerp doc中记录,但可以访问模型中定义的方法。

将以下代码添加到ttps://doc.openerp.com/6.1/developer/12_api/#xml-rpc-web-services的openerp_models.php文件中。下载提供的php lib

<?php

public function call_openerp_func($model, $function, $ids) {

    $client = new xmlrpc_client($this->server . "object");

    $id_val = array();
    $count = 0;
    foreach ($ids as $id) {
        $id_val[$count++] = new xmlrpcval($id, "int");
    }



    $this->msg = new xmlrpcmsg('execute');
    $this->msg->addParam(new xmlrpcval($this->database, "string"));
    $this->msg->addParam(new xmlrpcval($this->id, "int"));
    $this->msg->addParam(new xmlrpcval($this->password, "string"));
    $this->msg->addParam(new xmlrpcval($model, "string"));
    $this->msg->addParam(new xmlrpcval($function, "string"));
    $this->msg->addParam(new xmlrpcval($id_val, "array"));
    //////         
     */
    // Functions return values
    $this->res = &$this->client->send($this->msg);
    if ($this->res->faultCode()) {
        return 'Error: ' . $resp->faultString();
    } else {
        $res = $this->res->value();
        return $res;
    }
}
 ?>

这就是你如何调用上面的函数

<?php
  // sample for calling function to validate invoice payment
   $validate_voucher_payment = $kengen_model->call_function_func('account.voucher', 
      'button_proforma_voucher', array(8));  
?>

希望这能解决您的问题

答案 2 :(得分:0)

您可以尝试使用

来使用网络服务

Python,Ruby,PHP和Java编程语言

只需按照以下链接

https://www.odoo.com/documentation/8.0/api_integration.html

我希望我的回答对您有所帮助:)。