Odoo Help


How to read the diferent values of a filed company_dependent (Property field)?

Anabela Damas
on 3/15/16, 8:13 AM 2,368 views


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",

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?



Damien Bouvy (dbo)

--Damien Bouvy (dbo)--

| 1 0 1
Grand-Rosière, Belgium
--Damien Bouvy (dbo)--

Damien is part of the Odoo R&D department. He has taken part in the development of several features in Odoo, including the Subscription application, the Sales application, the frontend portal and the payment acquirers.

Nowadays he commits on our internal codebase, maintaining the billing process of Odoo.com, developing external tools and internal processes. More recently, he took part in the development of the Odoo.sh platform.

Damien Bouvy (dbo)
On 3/16/16, 5:39 PM

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.

Damien Bouvy (dbo)
on 3/16/16, 5:40 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/15/16, 8:13 AM
Seen: 2368 times
Last updated: 3/23/16, 10:16 AM