Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1566 Lượt xem

The problem:


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



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.


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.


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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

His solution doesnt work for now. I use the  he sudo() method when  execute the search() method but the console show me the following error Odoorpc.error.RPCerror: Tuple index out of range. 

How I can solve this. I am trying with Sudo true now.

Ảnh đại diện
Huỷ bỏ

Tuple index out of range is not because of using the sudo(), it is from the condition you passed for journal_id. maybe there is no value in bank_journal_id[0]. so try removing that condition and check if it works.

Câu trả lời hay nhất

Hi,

The sudo() method will execute the search() method with the permissions of the administrator user,

Update your code like this and try,

​ payment_ids = odoo.env['account.payment'].sudo().search([('partner_id', 'in', all_company_ids), ​('journal_id', '=', bank_journal_id[0]), ('state', '= ', 'posted')])  

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 25
5887
0
thg 7 21
2415
2
thg 2 20
3327
2
thg 1 19
3239
1
thg 11 16
5512