Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
1548 Näkymät

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
Hylkää
Tekijä Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
elok. 24
642
1
elok. 24
884
1
elok. 24
719
1
lokak. 24
934
1
tammik. 25
9748