php - 从 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>");
}
?>
解决方案
推荐阅读
- regex - 删除一行中第一个逗号字符之后和固定字符串之前的所有逗号
- swift - 数据更新后tableview不重新加载数据
- javascript - 从句子开头开始的 Twitter 预输入匹配
- sas - SAS:循环求和行从1到列指定的值
- python - Python 类派生自具有 list/DataFrame 属性的 pandas DataFrame
- string - Powershell 计算文件中的行数
- asp.net-core - 如何获取托管环境.net core 2的目录以上传文件
- html - 向网站发布数据时在 URL 中隐藏 index.php
- ballerina - 将记录转换为包含 time:Time 类型(或任何其他对象类型)的 JSON
- html - 由标签中超过最大宽度的单词组成的文本不会换行,即使定义了最大宽度、分词和溢出换行