Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
6486 Vues

Hai , 

i want to question ...

Why invisible field can't work, 

I will to invisible field 'birth_date' when I choose customer (with type field is boolean) ...

eg :

I make code in file .py :

'customer': fields.boolean('Customer'),

'birth_date':fields.date('Birth Date'),

 

and , make code in file .xml :

<record model="ir.ui.view" id="res_partner_formTop2_view">
            <field name="name">Position Top2</field>            
            <field name="model">res.partner</field>            
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <field name="function" position="before">
                    <field name="customer"/>
                </field>
            </field>
        </record>

 

<record model="ir.ui.view" id="res_partner_form5_view">
            <field name="name">master customer</field>            
            <field name="model">res.partner</field>            
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <field name="phone" position="before">
                    <field name="birth_date" attrs="{'invisible': [('customer','!=', True)]}"/>
                </field>
            </field>
        </record>

how I fix my problem ?

Avatar
Ignorer

Does it get invisible when the check box "customer" is not selected? I think you should write as {'invisible':[('customer','=',True)]}. So when you will select the check box it will invisible the field.

Auteur

Ok thanks Emipro Technologies Pvt. Ltd, I want to try your suggestion

Meilleure réponse

Hello Heru,

I guess you have same customer field twice in your partner form. Existing field you can see in Sales & Purchases tab. So syste gets confuse which one to consider.

So if you want to change the position of the field, you should first replace it and then add that field again with desired position.

Try following code:

<!-- Replace existing one first -->
<field name="function" position="replace"/>
<!-- Add the field again at desired position -->
<field name="function" position="before">
    <field name="customer"/>
</field>

customer boolean field is already defined in base module, so you don't have to define it again.

Avatar
Ignorer
Auteur

Ok thanks Sudhir Arya, I want to try your suggestion

Auteur

yes, it's work ... thanks Sudhir .. Sudhir, can you help me, what I use method when we fill field in form, but automatic filled in another form . ex : i have 1 field (engine number) is same in 2 form ('Work Order', 'Picking Slip'). i fill field 'engine number' in form 'Work Order' , when i click button save, field 'engine number' in form 'Picking Slip' automatic is filled.

Meilleure réponse

<field name="function" position="replace"/>
<!-- Add the field again at desired position -->
<field name="function" position="before">
    <field name="customer"/>
</field>

Avatar
Ignorer