2012-02-14 85 views
0

我需要將開放的erp hr模塊與php網站集成。爲此我嘗試使用XML-RPC。 但我沒有得到如何訪問它的method.I需要使用開放erp中的休假,時間表和工資計算。如何從PHP訪問OPENERP方法?

回答

0

您可以像訪問其他CRUD方法一樣訪問openerp中的方法。 它在openerp文檔中沒有記錄,但可以訪問模型中定義的方法。

將以下代碼添加到來自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)); 
?> 

希望這能解決你的問題