khaled bed
khaled bed

Reputation: 33

How to hide a field programmatically in Odoo?

I am trying to make a module for Odoo and I don't know how to hide a field using python code This line doesn't work for me :

'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),

I want to hide it using python and not using xml because I didn't declare that many2one field in my xml it's just a simple field in my test relation, the field will be created inside the popup to create new "formation".

This is the definition of the field that make the relationship

    'test_form_ids': fields.one2many('dev.form', 'form_id','formations'),

test_form_ids one2many field capture

This is my formation class

class dev_form(osv.Model):
_name='dev.form'
_description='rel between test & formations'

_columns = {
    'name': fields.many2one('dev.name', 'Formation'),
  'form_id': fields.many2one('dev.test', 'candidat', select=False,invisible=True),
}

highlighted the field I want to hide here the popup to create new formation capture

Upvotes: 2

Views: 7901

Answers (1)

Bhavesh Odedra
Bhavesh Odedra

Reputation: 11143

You need to open your view .xml file where cand_lan_id you declared.

Now replace field

<field name="cand_lan_id"/>

with

<field name="cand_lan_id" invisible="1"/>

invisible="1" is attribute which will hide your field from the User.

EDIT:

Open .xml file in which test_form_ids field is declare.

Now replace field

<field name="test_form_ids"/>

with

<field name="test_form_ids">
    <form string="Form Name">
        <field name="name"/>
        <field name="form_id" invisible="1"/>
        <!-- List of field that User want to see in form view -->
    </form>
    <tree string="Form Name" editable="bottom">
        <field name="name"/>
        <!-- List of field that User want to see as a columns -->
    </tree>
</field>

Upvotes: 2

Related Questions