Hide a field using Selection odoo


.py selection field.

class sale_order(osv.osv):
    _inherit="sale.order"
    _columns ={
        'resource_selection':fields.selection([
                                               ('customer','Customer'),
                                               ('lead','Lead'),
                                               ],default='customer'),
    }

.xml file

<record id="ep_sale_view_order_form" model="ir.ui.view">
   <field name="name">Sale</field>
   <field name="model">sale.order</field>
   <field name="inherit_id" ref="sale.view_order_form"/>
   <field name="arch" type="xml">
              <xpath expr="//field[@name='partner_id']" position="before">
                  <field name="resource_selection" string="Resource"/>

             </xpath>
              <field name="partner_id"  position="replace">
                  <field name="partner_id" attrs="{'invisible':[('resource_selection','=','lead')]}" />
              </field>
   </field>
</record>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s