nuw*_*aus 0 php xml-rpc odoo-9
如何使用 xmlrpc 将交货订单设置为“完成”?
我在用着
$client->write('stock.move', array(58), ['state' => "done"]);
Run Code Online (Sandbox Code Playgroud)
它确实有效,但不会更新现有数量,只有预测数量会更新。
有没有办法从 PHP 调用exec_workflow?
我最近在处理 Odoo 11 的 PHP XMLRPC 端点时遇到了同样的问题,我偶然发现了这篇文章和其他一些甚至更旧的文章,但他们都没有足够详细地回答这个问题,可以为我提供一个可行的解决方案。也就是说,这就是我最终为解决您遇到的问题所做的事情(设置交货订单状态或“完成”并更新现有数量)。
\n我的解决方案需要两次 API 调用,而不是一次,您将需要stock.pickingid 和任何相关的 stock.move id。我还创建了一个名为 OdooXmlrpc 的简单类来处理对 Odoo 的 XMLRPC 调用。我假设您已经做了同样的事情,因为您的代码片段似乎正在调用 $client 对象上的方法。I\xe2\x80\x99ll 包括下面我的类方法以供参考。
现在是代码片段。使用 PHP,我做的第一件事是为拣货中的每个产品/项目设置 stock.move 的 \xe2\x80\x98quantity_done\xe2\x80\x99 字段,因为这是用于现有数量的字段更新。您不必为 stock.picking 或stock.move,Odoo 将在我们调用第二个execute_kw 函数时设置这些字段。
// first we update the stock.move qty done\n$update_move_data = array(array($move['id']), array('quantity_done' => $move['product_qty']));\n$update_move = $xmlrpc_client->write('stock.move', $update_move_data);\nRun Code Online (Sandbox Code Playgroud)\n或者使用您的语法和一些虚拟数据
\n$xmlrpc_client->write('stock.move', array(58), ['quantity_done' => 50]);\nRun Code Online (Sandbox Code Playgroud)\n接下来,我调用我在类中创建的名为“call_function”的通用方法来处理交货订单传输。此类方法将接受 Odoo 模型和方法。理论上,我可以将此类方法用于任何 CRUD 操作,但我保留所有基于非 CRUD 的操作的使用,因为参数会有所不同 \xe2\x80\x93 仍在进行中,但似乎有用且目前有效。
\n// next we process the picking so its gets marked as done and qty on hand gets adjusted\n$picking_do_transfer = $xmlrpc_client->call_function('stock.picking', 'do_transfer', array($picking['id']));\nRun Code Online (Sandbox Code Playgroud)\n那\xe2\x80\x99就是它!交货订单状态现在为“完成”,并且系统中的现有数量应该已正确更新。
\n请注意,使用此“do_transfer”方法,Odoo 将为任何没有设置Quantity_done 值的项目/移动自动创建缺货订单,我发现这非常有用。希望此回复对您和任何其他偶然发现它的用户有所帮助。
\n我的OdooXmlrpc类方法供参考:
\n/**\n* Write the records respective to the IDs and field value pairs provided\n*\n* @param (string) $model, the Odoo model to be used in the call\n* @param (array) $domain, a multi-dim array of record ids and a mapping of updated fields to values\n*\n* @return (int) $ret, 1 when operation was successful\n*/\nfunction write($model, $domain) {\n if (!isset($model) || !isset($domain)) {\n print "Missing params...";\n return;\n }\n // our odoo method\n $method = 'write';\n $ret = $this->client->execute_kw($this->database, $this->id, $this->password, $model, $method, $domain);\n return $ret;\n}\n\n/** !NOTE! EXPERIMENTAL: NOT SURE WORKS WITH ALL ODOO MODELS\n* Call the model function with IDs and/or field values to run/update with\n*\n* @param (string) $model, the odoo model to be used in the call\n* @param (array) $method, the name of the model method to call\n* @param (array) $args, an array of id(s) or records to modify\n*\n* @return (int) $ret, 1 when operation was successful\n*/\nfunction call_function($model, $method, $args) {\n if (!isset($model) || !isset($method) || !isset($args)) {\n print "Missing params...";\n return;\n }\n $ret = $this->client->execute_kw($this->database, $this->id, $this->password, $model, $method, $args);\n return $ret;\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1501 次 |
| 最近记录: |