コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1751 ビュー

In my database, I'd like to create an action on the sales order that archives any associated tasks. However, I'm running into this error when salespeople run the action: 


"You are not allowed to modify 'Task' (project.task) records.


This operation is allowed for the following groups:

- Project/User


Contact your administrator to request access if necessary."

アバター
破棄
著作者 最善の回答

We can insert "sudo()" into our function to bypass any access right or record rule restrictions the logged in user has. Supposing the code looks something like this:


for line in record.order_line:

  to_archive = env['project.task'].search([('sale_line_id','=',line.id)])

  to_archive.write({'active': 0})


We can modify it to the following:


for line in record.order_line:

  to_archive = env['project.task'].search([('sale_line_id','=',line.id)])

  to_archive.sudo().write({'active': 0})


アバター
破棄
関連投稿 返信 ビュー 活動
1
8月 24
811
1
8月 24
1106
1
8月 24
894
1
10月 24
1153
1
1月 25
10171