Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
16072 Представления

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 

Аватар
Отменить
Лучший ответ

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.


Аватар
Отменить

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

Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
мар. 15
5526
1
мая 20
3357
3
нояб. 15
4730
1
окт. 24
11759
0
окт. 22
1625