Skip to Content
Menu
This question has been flagged
4 Replies
2991 Views

How to create a custom field with Yes/No Option

Avatar
Discard
Best Answer

Hello Senthil,


Try below code which is used in my Project Module.


custom_project.py :-

class project(models.Model):

    _inherit = 'project.project'


     exist_project = fields.Selection([('yes','Yes'),('no','No')], string="Is existing project ?")



custom_project_view.xml :-

<odoo>

    <record model="ir.ui.view" id="project_inherit_form">

        <field name="name">project.inherit.form</field>

        <field name="model">project.project</field>

        <field name="inherit_id" ref="project.edit_project"/>

        <field name="arch" type="xml">    

            <xpath expr="/form/sheet/div[@class='oe_title']/div[@name='options_active']" position="after">

                <group>

                    <group>

                        <field name="exist_project" />
                    </group>

                </group>   

            </xpath>

        </field>

    </record>

</odoo>


Hope this works for you. 


Avatar
Discard
Best Answer

You can add attrs for that if you don't want to see in supplier then you have to user this attrs:


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

Avatar
Discard
Author Best Answer

Thank you Jignesh. When ever I add a custom field in customer master, the same fields are getting displayed in supplier master also. How do I make it visible only in customer master??

Avatar
Discard

given ans on the question which is asked by you.