跳至內容
選單
此問題已被標幟
2 回覆
2440 瀏覽次數

Hi, new odoo ce user, trying to sort my issues. image below pretty much shows context precisely, i wanted to access linked Work Orders . Any ideas, huge thanks in advance.  

      

頭像
捨棄
最佳答案

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')])

頭像
捨棄
作者 最佳答案

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)

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
7月 25
400
1
9月 24
2054
1
8月 24
2101
1
1月 23
3044
3
1月 23
10897