콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2942 화면

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 .

아바타
취소
관련 게시물 답글 화면 활동
1
9월 24
2432
1
8월 22
2776
0
10월 16
3048
3
7월 15
4305
How to do this? 해결 완료
1
3월 15
3984