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

When I create a company, one partner is also created

How can I detect which partner is created by company?

I tried printing self._context in res.partner's create function but there is nothing to indicate this partner was created from the company.

Or how to send context value to res.partner when I create company?

I am using Odoo version 15.

Thanks!

아바타
취소
베스트 답변

Hi Anhnt,

You can find the field "Contact" inside the company's General Information page. It is the partner record of the company. You can click on it to see the partner record detail.

Company's partner is creating by the create method of the company. The partner will be the same name with the "is_company" field as true,  "commercial_partner_id" as the company id and that partner has no parent record id.

Hope it will help you.


아바타
취소
작성자

Thank you!
It show me which partner is company.

But I want to inherit res.partner's create function to detect that the partner is created from the company and then add my custom data to some fields.

Instead of partner's create method, you can inherit company's create method and then you can write your datas in company "s partner.

For particular partner, you have to consider partner type and commercial_partner_id fields.

작성자

Thank you very much!
I inherited company's create method and my problem is solved.
I had a little trouble finding the company's create method because it is base method.
But I finally found it in odoo/addons/base/models/res_company.py.

Thank you!

Hi Anhnt,
Please vote up the answer.
Thank you.

관련 게시물 답글 화면 활동
2
10월 24
2013
3
4월 20
10982
2
10월 23
6003
3
9월 23
2874
0
5월 23
2858