Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2844 มุมมอง

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

อวตาร
ละทิ้ง

Which Odoo version ?

ผู้เขียน

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

ผู้เขียน

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}])

ผู้เขียน

Version 12

คำตอบที่ดีที่สุด

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 .

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 24
2232
1
ส.ค. 22
2691
0
ต.ค. 16
2934
3
ก.ค. 15
4197
How to do this? แก้ไขแล้ว
1
มี.ค. 15
3872