Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

how to access planned WorkOrders record list from Manufacturing Order (in python)

形象
odoo
形象
丢弃
2 答案
0
形象
odoo
最佳答案

The better way to go about this would be to use self.env to perform the search. The code you have executes an XMLRPC event. Using self.env, your code would look like

result = self.env['mrp.workorder'].search([('production_id', '=', '3')])

形象
丢弃
0
形象
odoo
最佳答案

not sure, this is best answer, but atlease i managed to solve this, by adding line below in python function :)

for xml rpc (external client)

result = models.execute_kw(db, uid, password, 'mrp.workorder', 'search', [[['production_id
...: ', '=', 3]]])

For Module Code(using self.env)


  • simple search records

relWorkOrders = self.env['mrp.workorder'].search([('production_id','=',self.id)])

  • search and read specific fields in one go (i ended up using this)

mo = self.env['mrp.workorder']

wo_fields = ['name','state','workcenter_id']

relWorkOrdersData = mo.search_read([('production_id','=',self.id)],wo_fields)

形象
丢弃