php xmlrpc搜索错误odoo 10

时间:2016-12-19 10:29:18

标签: php xml-rpc odoo-9

当我想在Odoo 10内进行研究以获取值时,我遇到此错误。在Odoo 8,我没有问题。

  

致命错误:未捕获错误:调用成员函数scalarval()   整数

问题来自这一行:$ids = $val->scalarval();

如果我在scalarval()

之前这样做
 $val = $response->value();

响应

 var_dump($val);
 int(0) 

想要解决这个问题?

功能

Public function odooSearch($attribute, $operator, $keys, $relation, $string = 'string', $offset = 0, $limit = 1 ) {

  $client = new \xmlrpc_client($this->server_url . "/xmlrpc/object");
  $client->setSSLVerifyPeer(0);

  $domain_filter = array(new \xmlrpcval(
                            array(new \xmlrpcval($attribute , "string"),
                                  new \xmlrpcval($operator,"string"),
                                  new \xmlrpcval($keys, $string),),"array"),);

  $msg = new \xmlrpcmsg('execute');
  $msg->addParam(new \xmlrpcval($this->database, "string"));
  $msg->addParam(new \xmlrpcval($this->id, "int"));
  $msg->addParam(new \xmlrpcval($this->password, "string"));
  $msg->addParam(new \xmlrpcval($relation, "string"));
  $msg->addParam(new \xmlrpcval("search", "string"));
  $msg->addParam(new \xmlrpcval($domain_filter, "array"));
  $msg->addParam(new \xmlrpcval($offset, "int")); // OFFSET, START FROM
  $msg->addParam(new \xmlrpcval($limit, "int")); // MAX RECORD LIMITS

  $response = $client->send($msg);

  $val = $response->value();
  $ids = $val->scalarval();

  return $this->traverse_structure($ids);
}

我通过此函数调用该函数,例如

  function osc_cfg_use_function_config_create_wharehouse() {

    $OSCOM_ODOO = Registry::get('Odoo');
    $OSCOM_Db = Registry::get('Db');

    if (ODOO_WHAREHOUSE_CONFIG == 'configure' && ODOO_ACTIVATE_WEB_SERVICE == 'true') {

      $company_id = $OSCOM_ODOO->getSearchCompanyIdOdoo();
      $date = date("Y-m-d H:i:s");

// Stock Management
      $ids = $OSCOM_ODOO->odooSearchByTwoCriteria('company_id', '=', $company_id, 'stock.warehouse', 'int',
        'name', '=',  'ClicShopping', 'string');
// read id company odoo
      $field_list = array('id');

      $company_id_wharehouse = $OSCOM_ODOO->readOdoo($ids, $field_list, 'stock.warehouse');
      $company_id_wharehouse = $company_id_wharehouse[0][id];

      if (empty($company_id_wharehouse)) {

        $values = array("name" => new xmlrpcval('ClicShopping', "string"),
                        "code" => new xmlrpcval('CL', "string"),
                        "partner_id" => new xmlrpcval($company_id, "int"),
        );

        $OSCOM_ODOO->createOdoo($values, "stock.warehouse");

      } else {

        $values = array("name" => new xmlrpcval('ClicShopping', "string"),
                        "code" => new xmlrpcval('CL', "string"),
                        "partner_id" => new xmlrpcval($company_id, "int"),
        );

        $OSCOM_ODOO->updateOdoo($company_id_wharehouse, $values, "stock.warehouse");

      }

// Inventory creation
// search location name and id in stock location
      $ids = $OSCOM_ODOO->odooSearch('name', '=', "CL", 'stock.location');

      $field_list = array('id',
                          'location_id',
                          'name',
      );

      $Qstock_location = $OSCOM_ODOO->readOdoo($ids, $field_list, 'stock.location');
      $stock_location_id = $Qstock_location[0][id];
      $stock_location_name = $Qstock_location[0][name];

      $stock_location_id = $stock_location_id + 1;

      $values = array("name" => new xmlrpcval("ClicShopping", "string"),
                      "date" => new xmlrpcval($date, "string"),
                      "company_id" => new xmlrpcval($company_id, "int"),
                      "location_id" => new xmlrpcval($stock_location_id, "int"),
                      "filter" => new xmlrpcval('none', "string"),
      );

      $OSCOM_ODOO->createOdoo($values, "stock.inventory");


      $Qupdate = $OSCOM_Db->prepare('update :table_configuration
                                      set configuration_value = :configuration_value
                                      where configuration_key = :configuration_key
                                    ');
      $Qupdate->bindValue(':configuration_value', 'false');
      $Qupdate->bindValue(':configuration_key', 'ODOO_WHAREHOUSE_CONFIG');
      $Qupdate->execute();
    }
  }

0 个答案:

没有答案