首页 > 解决方案 > 从 PHP 脚本在 odoo 中制作 POS

问题描述

我有一个 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>");
  }


  ?>

标签: phpodoo

解决方案


推荐阅读