Skip to Content
Menu
This question has been flagged
1 Reply
1352 Views

Hello, I am working on a payment plugin for odoo 16.

After a payment during the processing, i try to access a fonction that is in the payment_provider.py files by using tx.provider_id.my_function()

When i do that i get the following error : 

Access Denied by ACLs for operation: read, uid: 4, model: payment.provider

You are not allowed to access 'Payment Provider' (payment.provider) records.

This operation is allowed for the following groups:

- Administration/Settings


Contact your administrator to request access if necessary.


I don't want the user to have to modify the right of some groups to make the application work.

How should i proceed to be able to call that function everytime.


Avatar
Discard
Best Answer

The error you're encountering indicates that the user does not have sufficient access rights to read records of the payment.
By calling sudo() on the provider_id, you temporarily gain administrative privileges to access the record and call the function. This approach is useful when you need to perform operations that require elevated permissions.

tx.provider_id.my_function() is failing.
# Use sudo() to bypass ACLs

provider = tx.provider_id.sudo()

result = provider.my_function()

Avatar
Discard
Author

Hi, thanks for the answer. Unfortunatly after using your idea, i still have the same exact error. Is this a bug comming from somewhere else? Do you have an idea about where it could be from?

Author

It was a .sudo() problem, just not where i thought it was.
Thanks for the help.

Related Posts Replies Views Activity
0
Jul 24
610
1
Aug 24
504
1
Jul 24
544
2
Mar 24
3237
0
Sep 24
603