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

Hi, 

In the python the field is defined like this : 

property_account_payable_id = fields.Many2one('account.account', company_dependent=True,
string="Account Payable", oldname="property_account_payable",
domain="[('internal_type', '=', 'payable'), ('deprecated', '=', False)]",
help="This account will be used instead of the default one as the payable account for the current partner",
required=True)

So when I log in with a user of company1 I see one value, if I log in with a user from company2 for this field I see other value. 


I'm changing the workflow of sale order and I need to know how to read this value for each company that I've.

I manage to do this, like this:

user_company2 = self.env['res.users'].search( [('id','=',6)])
self.env['res.partner'].sudo(user_company2).search( [('id','=',6)]).property_account_receivable_id.id

But I wanted to read the information base on the changing of the company not the changing of the user !
Is there away to read this depending on the company


Now I know that this is a  Property Field:

There is some use cases where value of the field must change depending of the current company.
To activate such behavior you can now use the company_dependent option.
A notable evolution in new API is that “property fields” are now searchable.

My question now, is how do I search this field in order to have all information mapped by company? 

In database the information is like this:

"2";"";;"2016-02-08 17:43:44.125127";"property_account_receivable_id";1;"many2one";1;1;2552;"";"<binary data>";"2016-02-08 17:43:44.125127";"account.account,9";;""

"25";"";;"2016-02-26 16:35:43.02136";"property_account_receivable_id";1;"many2one";4;1;2552;"";"<binary data>";"2016-02-26 16:35:43.02136";"account.account,388";;""

"32";"";;"2016-02-26 16:36:04.669278";"property_account_receivable_id";1;"many2one";6;1;2552;"";"<binary data>";"2016-02-26 16:36:04.669278";"account.account,767";;""

Maybe there is a function already implemented that is possible to search all values possible to a field depending on the company?

Thanks 

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

I'm not 100% sure but you *could* try to evaluate it with 'force_company' in the context:

self.env['res.partner'].with_context(force_company=2).search( [('id','=',6)]).property_account_receivable_id.id

Again, this might not work given ir_rules (maybe your user need the multi company group + have that specific company set as available to its user). But it's my best bet.


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

I don't think it's possible to get all values for a given property using the standard code though.

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

Hi, 
You can refer following link for this, It has complete explanation with code for company dependent fields and other multi-company features:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
5959
1
thg 5 20
3856
3
thg 11 15
5161
creation of company Đã xử lý
1
thg 10 24
12399
0
thg 10 22
2121