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

Hi There,


I'm trying to get all the invoices that are in the accounting of two companies (CompanyXYZ Inc. and CompanyXYZ SA). In the UI, I do have first to select the company and then navigate to the Accounting module and select the Sales book (landing in the model account.invoice).


In my python code, when I submit the following code:

models.execute_kw(db, uid, password, 'account.invoice, 'search_read', {}

I either get the list of invoices belonging to the INC or to the SA but not both. Also, I noticed that I get the list from company I last logged in in the web interface. (Say I log in and select "Company Inc", and then I run my python code, I'll get the invoices from the INC. If I then switch the SA, and run the same Python code again, then I'll get the invoices from the SA.


What am I missing? Is there a way to provide a parameter in the XMLRPC request to indicate which company I'm connecting to?


Thanks,

François

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

Which Odoo version ?

Tác giả

Thanks for your response Alessandro. It makes total sense. I tried the following ro update the company: models.execute_kw(db, uid, password, 'res.partner', 'write', [[1786],{'company_id','=',[1,'Company XYZ SA']}]) but got the following error message: TypeError: unhashable type: 'list' Not sure what I'm doing wrong but it looks like companyId is a list

Tác giả

Please ignore my previous comment. Thank you SO much Alessandro! The correct syntax to switch companies is: models.execute_kw(db, uid, password, 'res.users', 'write', [[uid],{'company_id':1}])

Tác giả

Version 12

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

You can first call the write method on the res.users model for the uid used for the connection writing in the company_id field the id of the company you want to work with in subsequent methods.

This is the same operation that the web ui does when changing the active company .

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 24
2236
1
thg 8 22
2696
0
thg 10 16
2950
3
thg 7 15
4204
How to do this? Đã xử lý
1
thg 3 15
3878