Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1546 Visualizzazioni

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."

Avatar
Abbandona
Autore Risposta migliore

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})


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
ago 24
641
1
ago 24
883
1
ago 24
718
1
ott 24
933
1
gen 25
9741