简体   繁体   English

如何使用xml-rpc在Odoo中消费和产生制造订单?

[英]How do I consume and produce a manufacturing order in Odoo using xml-rpc?

I'm creating the order like this: 我正在创建这样的订单:

new_manufacturing = models.execute_kw(db, uid, password,
'mrp.production', 'create',
[{'name':'M0001','product_id':155,'product_uom':1, 'bom_id':54, 'state':'draft'
}],)

and then make it ready to production,then production started, 然后准备生产,然后开始生产,

reserve_materials = models.execute_kw(db, uid, password,
'mrp.production', 'force_production',
 [[new_man],{'context':False}])

start_production = models.execute_kw(db, uid, password,
 'mrp.production', 'action_in_production',
  [[new_man],{'context':False}])

but when I do: 但是当我这样做时:

 consume = models.execute_kw(db, uid, password,
  'mrp.production', 'action_produce',
   [new_manufacturing,1.00,['consume_produce']])

it doesn't consume the bill of materials and the product does NOT appear in inventory. 它不会消耗物料清单,并且该产品不会出现在库存中。 (even though the message Production produced is there). (即使消息生产产生在那里)。

PS I need to use the webservice API as I don't have aces to change the code on server printscreen from app PS我需要使用Web服务API,因为我没有Ace可以从应用程序更改服务器打印屏幕上的代码

Assuming that you are using v9 or higher version here. 假设您在此处使用的是v9或更高版本。 Note here that you are using v9 MRP and that has workflow associated to each record and you are calling direct Object mrp.production methods to manipulate record but it will fail reason being workflow Engine will reject your operation that you trying to by-pass. 请注意,这里您使用的是v9 MRP,并且每个记录都有工作流程,并且正在调用直接Object mrp.production方法来处理记录,但是由于工作流程引擎将拒绝您尝试绕过的操作,因此将失败。 Below ic correct code that calls workflow and also it call consume wizard and trigger it correct to consume it: 在ic下方的正确代码可以调用工作流程,还可以调用消耗向导并触发它正确使用它:

# Create a Production record
new_manufacturing = models.execute_kw(db, uid, password,
            'mrp.production', 'create',
            [{'product_id':34,'product_uom':1, 'bom_id':4, 'product_qty': 1.0}],)

# Call workflow to confirm production.
models.exec_workflow(db, uid, password, "mrp.production", 'button_confirm', new_manufacturing)

# Force reserve dreictly as its not part workflow  for mrp
models.execute_kw(db, uid, password, 'mrp.production', 'force_production', [new_manufacturing])

#prepare context consume product wizard.
context={'active_id': new_manufacturing, 'active_ids': [new_manufacturing], "active_model": "mrp.production"}
# Create a consume wizar object 
produce_id = models.execute_kw(db, uid, password,
'mrp.product.produce', 'create',
[{'product_id':34, 'product_qty': 1.0, 'mode': 'consume_produce'}, context])

# execue Consume wizard to trigger final workflow record.
models.execute_kw(db, uid, password, 'mrp.product.produce', 'do_produce', [[produce_id], context])

also while creating mrp.prodution do not pass state or name are they have default value generate by system. 同样,在创建mrp.prodution时不传递状态或名称,因为它们具有系统生成的默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM