Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1455 Представления

I have a server action that performs some operation based on the value of the current record context, but odoo forbids calling a server action on a record when write permission is not accorded.

I'm questioning why is it necessary to check for write permission before launching the server action and how can I work around this.

I can inherit the model and override the method but I want to know if there is another solution.

 This is the link to the code that checks for the permission is located in the run method of IrActionsServer model inside the ir_actions file


Thanks,

Аватар
Отменить
Лучший ответ

Hi,


Odoo enforces write permissions before running a server action because server actions can modify records, and this prevents users with only read rights from indirectly changing data.


If your server action is read-only, you can work around this by using .sudo() inside the Python code so it bypasses write checks while still keeping logic safe. If it needs to update records, the user should logically have write access.


Other options include using a custom button/cron job instead of a server action, or assigning a dedicated security group with the needed rights. Overriding the global check in ir.actions.server.run is possible but not recommended, since it weakens security.


Hope it helps

Аватар
Отменить
Лучший ответ

You were super close, just add allowed groups_id​to the record, and it would not ask for write permissions

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
окт. 23
5795
1
нояб. 23
3423
5
сент. 25
23081
3
авг. 25
3431
1
мая 25
3337