du3932066 2019-05-22 21:16
浏览 89

使用PHP脚本在POSoo中创建POS

I have an php script, with this i will make an POS into odoo, but i need make a POS Reference and ID Session for this pos (point of sale). I can´t make it because the pos reference need the id session but i don´t know how.

I think that i need to run, the point of sale for obtaining the session id. The pos is created without issues, but i need make associating to one of point of sale.

This is the script.-

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


  ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3