Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
5146 มุมมอง

Hi everyone. I am sure there is an easy answer to this that I cannot find.


How do you add a custom field to a radio selection.

i.e. in res.partner company_type radio selection - individual and company

    we need to add a new field specific to the individual not the company.

    so it does not need to be seen on company form just individual


thanks in advance  

อวตาร
ละทิ้ง

Hi Justin: What are you using to do the customization - Studio or python module ?

ผู้เขียน

Python inherit

คำตอบที่ดีที่สุด

Hi Justin:

You will need to do 2 things:

  1. Add a new field to the model

  2. Display the field in the view and make it visible only when the contact is an individual

In your example, define the field, spouse, in the model. Then add the field to the view and make it visible only for individuals like so by making it invisible if the contact is a company.

<field name="spouse" attrs="{'invisible': [('is_company', '=', True)]}" />

NOTE: I'm assuming you're familiar with using inheritance for models and views to make the necessary changes.

อวตาร
ละทิ้ง
ผู้เขียน

Thank you, I do understand inheritance. Just didn't know if that string belonged in the models or xml. Looking at it the correct xpath would be-

<xpath expr="//field[@name='mobile']/.." position="after">

<label for="spouse"/>

<div>

<field name="spouse" attrs="{'invisible': [('is_company', '=', True)]}" />

</div>

</xpath>

Thanks again

คำตอบที่ดีที่สุด

Just do like this : <field name="gender" widget='radio' options="{'horizontal': true}"/>

Python: gender = fields.Selection([('foo', 'foooooooo'), ('bar', 'baaaaaaaar')], default='foo')


อวตาร
ละทิ้ง
ผู้เขียน

hmmm I don't want to add another selection field. Lets say I want to add a spouse = fields.Char to foo. how would you present that in models and xml?

Related Posts ตอบกลับ มุมมอง กิจกรรม
5
ก.ย. 20
5061
Creating new view from a old view แก้ไขแล้ว
11
ม.ค. 24
13577
2
ส.ค. 20
3497
1
มิ.ย. 16
10192
1
มี.ค. 15
11433