コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
6483 ビュー

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 ?

アバター
破棄

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.

著作者

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

最善の回答

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.

アバター
破棄
著作者

Ok thanks Sudhir Arya, I want to try your suggestion

著作者

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.

最善の回答

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

アバター
破棄