从PHP脚本在odoo中生成POS

从PHP脚本在odoo中生成POS,php,odoo,Php,Odoo,我有一个php脚本,用它我将把一个POS转换成odoo,但是我需要为这个POS(销售点)创建一个POS引用和ID会话。我做不到,因为pos参考需要id会话,但我不知道如何进行 我想我需要运行销售点以获取会话id。pos创建时没有问题,但我需要与销售点之一关联 这是剧本- <?php $url ="http://localhost:8069"; $db = "testing"; $username= "myuser"; $password ="mypass"; re

我有一个php脚本,用它我将把一个POS转换成odoo,但是我需要为这个POS(销售点)创建一个POS引用和ID会话。我做不到,因为pos参考需要id会话,但我不知道如何进行

我想我需要运行销售点以获取会话id。pos创建时没有问题,但我需要与销售点之一关联

这是剧本-

  <?php
  $url ="http://localhost:8069";
  $db = "testing";
  $username= "myuser";
  $password ="mypass";

  require_once('ripcord.php');
  // Login to the account

  //$erp->createRecord('pos.session', array('pos_config_id' => $posConfigId, 'pos_session_id' => 'false'))

  $common = ripcord::client($url.'/xmlrpc/2/common');
  //print_r($common);
  $uid = $common->authenticate($db, $username, $password, array());
  //print_r($uid);
  $models = ripcord::client("$url/xmlrpc/2/object");
  //Session
  $new = $models->execute_kw($db, $uid, $password,
    'pos.session.opening', 'open_session_cb',
    array(array($new)),
    array()
  );

  $new = $models->execute_kw($db, $uid, $password,
      'pos.order', 'create',
      array(array('partner_id'=> 1168, //cliente
                'company_id' => 1, //
            'user_id' => 21, //Vendedor
                //'pos_reference' => 'Pedido $uid-001-0001',
                //'payment_term' => 1, //inmediate payment
                'state'=> 'paid',
                'note'=>'compra', //Notas
            'statement_ids'=> array(array(6,0,array(1))), //metodo de pago
            'pricelist_id'=>1,
            'session_id'=>$pos_session_id,
                  )));

      print("<p>created new sale order with id: ");
      print_r($new);
      print("</p>");

  // Create sale order line(s)
    $sale_order_line_id = $models->execute_kw($db, $uid, $password,
      'pos.order.line',
      'create',
      array(
          array(
              'order_id'=>$new, // Reference to the sale order itself
              'name'=>"10 Camaron / Palta / Queso Crema", //Sale order line description
              'product_id'=>140, // Products can be found from product_product
              'price_unit'=>2000.00, // Unit price
              'product_uom_qty' => 1.00, //taxes
        'tax_ids'=>array(array(6,0,array(1))),          
          )
      )
  );

  if(is_int($sale_order_line_id)){
      print("<p>Invoice line created with id '{$sale_order_line_id}'</p>");
  }
  else{
      print("<p>Error: ");
      print($sale_order_line_id['faultString']);
      print("</p>");
  }


  ?>


您在第18行和第24行设置了两次,从而覆盖了
$new
的值,这可能不是全部问题,但可能有助于调试。thx,但效果很好。问题是,我不知道如何将销售点从php运行到obtaine会话,因为您在第18行和第24行上设置了两次,从而覆盖了
$new
的值,这可能不是全部问题,但可能有助于调试.thx,但效果很好。问题是我不知道如何将销售点从php运行到obtaine会话id