跳至內容
選單
此問題已被標幟
4 回覆
1495 瀏覽次數

Hi everyone,

When I create a new contact, the company_type is defined as person. I would like to set it to company by default.

So I created a model that inherited res.partner model, and I define is_company to True by default 

class ResPartner(models.Model):

    _inherit = 'res.partner'

    brand_name = fields.Char()

    is_company = fields.Boolean(default=True)

But it stays as person as default. 

What should I do ? 

Thanks a lot 

頭像
捨棄
最佳答案

I believe you can utilize user defaults for this purpose.

Enable debug mode.

Navigate to the contact page.

Tap on the debug icon.

Select the user defaults option.

頭像
捨棄
最佳答案

Hello Arthur LEHAVRE ,


Use this code you no need to override the is_company field.

class ResPartner(models.Model):
_inherit = 'res.partner'

@api.onchange('company_type')
def onchange_company_type(self):
rec = super().onchange_company_type()
self.is_company = False
return rec

Hope this helps!

Thanks & Regards,

Name : Yahoo Baba

Email:  yahoobaba077@gmail.com 

頭像
捨棄
作者 最佳答案

Thank you ! Indeed it works great ! And is there way to set it up in my model ?

頭像
捨棄
最佳答案

i think you can use user defaults 

activate debug mode

open the contact page 

press on debug icon

click on user defaults 


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
12月 24
1039
3
7月 25
2155
1
6月 25
2673
2
5月 25
2141
1
5月 25
1330