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

Custom Fields as a drop down

By
Senthil Kumar
on 12/21/15, 12:33 AM 321 views

How to create a custom field with Yes/No Option

1

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 12/21/15, 1:33 AM

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. 


0
Krupesh Laiya
On 12/21/15, 3:55 AM

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)]}"/>

0
Senthil Kumar
On 12/21/15, 1:38 AM

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??

given ans on the question which is asked by you.

Jignesh Mehta
on 12/21/15, 1:41 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: 12/21/15, 12:33 AM
Seen: 321 times
Last updated: 12/21/15, 3:55 AM