Odoo Help

Welcome!

This community 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.

0

Why do users have to have corresponding partner?

By
vim24
on 3/3/13, 10:51 PM 1,790 views

This seems like it probably has a basic answer, but its left me baffled. Why do users (res.users) and companies (res.company) each have a many2one 'partner_id' field? From my testing it seems this corresponding partner is what is used to check access rights rather than the user/company itself. But users and companies inherit from res.partner anyway...so why do they need this separate partner object linked to them?

Can anyone tell me what I am missing here?

4

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 3/4/13, 4:51 AM

For generalization purposes res.partner is used for personal data, regardless whether this is a customer, supplier, company or a user. This makes sense, because otherwise contact data will be spread over several tables. So there is for example only one E-Mail field in the whole system.

res.company does not inherit form res.partner.

res.user inherits from res.partner, but there are 2 types of inheritance (see Developer Docu)

  • _inherit and
  • _inherits

Since res.user uses the second type, it only is related to a res.partner with partner_id. But the fields of res.partner are not directly accessible (with _inherit they would be directly accessible, but the fields would then also be in the res.user table).

_inherits in this case assures that the contact data stay in DB table res_partner instead of res_user

Very useful answer, thank you. Can I further ask, why does res_user have a company_id field if res_partner already has the same field and is meant to handle all the 'personal' data?

vim24
on 3/12/13, 5:31 PM

In response to my own second-question. I believe I now know the answer to this. User's company_id refers to the currently worked on company whereas the user's partners company_id refers to the company to which the user is actually employed (although it defaults to the admins company). Please correct me if I'm wrong :)

vim24
on 3/13/13, 12:51 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/3/13, 10:51 PM
Seen: 1790 times
Last updated: 3/16/15, 8:10 AM