【问题标题】:how To Access OPENERP Methods From PHP?如何从 PHP 访问 OPENERP 方法?
【发布时间】:2012-02-14 09:49:36
【问题描述】:

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

【问题讨论】:

    标签: php xml-rpc openerp


    【解决方案1】:

    【讨论】:

    • 有没有办法使用orm方法从php页面访问和提交erp表单。
    【解决方案2】:

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

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

    <?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));  
    ?>
    

    希望这能解决您的问题

    【讨论】:

      【解决方案3】:

      您可以尝试使用网络服务

      Python 、Ruby 、PHP 和 Java 编程语言

      只需点击以下链接

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

      希望我的回答对你有帮助:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-09-08
        • 1970-01-01
        • 2021-07-09
        • 1970-01-01
        • 1970-01-01
        • 2014-04-17
        • 2012-12-21
        相关资源
        最近更新 更多