Odoo RPC Permission

47 views Asked by At

The problem:

In a configuration file there is a connection to Odoo using the OdooRPC library

import odoorpc from dotenv import load_dotenv import you

load_dotenv()

ODOO_HOST = os.environ.get('ODOO_HOST') ODOO_PORT = os.environ.get('ODOO_PORT')

Prepare the connection to the server

odoo = odoorpc.ODOO(ODOO_HOST, port=ODOO_PORT)

Check available databases

print(odoo.db.list())

Login

odoo.login(os.environ.get('ODOO_DATABASE_NAME'), os.environ.get('ODOO_DATABASE_USER'), os.environ.get('ODOO_DATABASE_PASSWORD'))

The credentials used in this connection are administrator credentials, but when making a query like this for a client:

payment_ids = odoo.env['account.payment'].search([('partner_id', 'in', all_company_ids), ('journal_id', '=', bank_journal_id[0]), ('state', '= ', 'posted')]) Searches the database using client permissions instead of administrator permissions.

Can you give me an idea how to solve this problem?

At the moment it has been solved by giving permissions to the clients (in this case to the account.payment model), but the ideal would be for odoo.env to always be able to search with administrator permissions so as not to have to give permissions to the clients or other way you think.

0

There are 0 answers