Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
5845 Weergaven

I have to hide the fields phone, mobile, and email in contacts, I believe I'm doing the right thing to do the trick but it seems that it's not behaving the way it should. Here's my code:

in inherited views..

​<record id="contacts_custom_fields" model="ir.ui.view">
    <field name="name">contacts.custom.fields</field>        
    <field name="model">res.partner</field>        
    <field name="type">form</field>        
    <field name="inherit_id" ref="base.view_partner_form"/>        
    <field name="arch" type="xml">
        <field name="phone" position="attributes">
            <attribute name="groups">module_name.group_admin,module_name.group_read_only</attribute>            
        </field>            
        <field name="mobile" position="attributes">                
            <attribute name="groups">module_name.group_admin,module_name.group_read_only</attribute>            
        </field>            
        <field name="email" position="attributes">                        
            <attribute name="groups">module_name.group_admin,module_name.group_read_only</attribute>            
        </field> 
    </field>
</record>

I also tried this to locate exactly the field but, to no avail:

​<record id="contacts_custom_fields" model="ir.ui.view">
    <field name="name">contacts.custom.fields</field>        
    <field name="model">res.partner</field>        
    <field name="type">form</field>        
    <field name="inherit_id" ref="base.view_partner_form"/>        
    <field name="arch" type="xml">
        <xpath expr="//form/sheet/group[1]/group[2]/field[@name='phone']" position="attributes">                
            <attribute name="groups">module_name.group_admin,module_name.group_read_only</attribute>            
        </xpath>
    </field>
</record>

For a test, I also even tried to use:  <attribute name="attrs">{'invisible': 1}</attribute> but to no avail

 Anyone, who encountered the same issue.? 

Avatar
Annuleer
Beste antwoord

hello

 please check the sms and mail module, into that the field phone and email is inherited and replace. so if you want to hide that field you have inherit the sms  and mail module.

Hope this will helps you.

Thank you.

Avatar
Annuleer
Auteur

Thanks man.. You are right.. I was able to hide the fields by inheriting the view in mail (for email).. And still have to work with the other fields. But your answer really helps me a lot..

Auteur

For someone's reference here's what I did:

<record id="res_partner_view_form_inherit_mail2" model="ir.ui.view">

<field name="name">res.partner.view.form.inherit.mail2</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="mail.res_partner_view_form_inherit_mail"/>

<field name="arch" type="xml">

<xpath expr="//label[@for='email']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

<xpath expr="//field[@name='email']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

</field>

</record>

<record id="partner_form_send_sms_form_view2" model="ir.ui.view">

<field name="name">partner_form_send_sms_form_view2</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="sms.partner_form_send_sms_form_view"/>

<field name="arch" type="xml">

<xpath expr="//label[@for='phone']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

<xpath expr="//label[@for='mobile']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

<xpath expr="//field[@name='phone']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

<xpath expr="//field[@name='mobile']" position="attributes">

<attribute name="groups">my_module.group_admin,my_module.group_read_only</attribute>

</xpath>

</field>

</record>

Beste antwoord

Hi,

   In order to hide a field use

<record id="contacts_custom_fields" model="ir.ui.view">
    <field name="name">contacts.custom.fields</field>        
    <field name="model">res.partner</field>        
    <field name="type">form</field>        
    <field name="inherit_id" ref="base.view_partner_form"/>        
    <field name="arch" type="xml">
<xpath expr="//field[@name='field_name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>

</field>

</record>

           

Avatar
Annuleer
Auteur

Thanks for your response. In this case, Mitul Shingala is right.. The answer you provided did hide but only the input field..

Gerelateerde posts Antwoorden Weergaven Activiteit
1
apr. 15
13336
1
aug. 24
2273
2
mei 24
3011
1
dec. 22
2805
2
mrt. 22
9913