Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Extend a view to hide fields in a form in v7?

By
Sean Samborski
on 4/10/14, 6:27 AM 1,789 views

For example, I want to hide field "Number of Children" on the employee form.

So I see it's field: children, object: hr.employee.

I have tried:

extend hr.employee

<field name="children" position="replace"/>
//Result XML validation error

<field name="marital" position="after">
  <field name="children" position="replace"/>
</field
//Exact code from the view, result, two Children fields (this code replace the Marital field with another Children)

<field name="children" attrs="{'invisible':[('children','=',True)]}"/>
//Passes validation but returns error when trying to open an employee form

<field name="children" position="attributes">
  <attribute name='invisible'>1</attribute>
</field>
//Fails xml validation

I don't know any of this code and I'm trying to find examples and that's where I got these tests from. Is there no default way to hide fields like with <field name="field_name" invisible="true"/> and I'm extending the form it will hide that field?

image description

1

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 4/10/14, 7:54 AM

Try this

image description

ValidateError

Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

Elephante, Sean Samborski
on 4/10/14, 1:14 PM

I get the above error when I try your method in the view. Maybe I have an incorrect setting somewhere?

Elephante, Sean Samborski
on 4/10/14, 1:15 PM

This is correct. If this is going into a module, you may not have the dependencies listed correctly in the __openerp__.py file.

Brett Lehrer
on 4/10/14, 2:06 PM

I'm only using this in an extended view. I haven't mastered the delicate art of creating a module that doesn't return the "No handler found" error. So for now this is only in a view. I think the problem I have found is the group this field is in. Since I'm hiding all the fields in group name="contract" I think it's not liking it. How do you hide a group? I've tried position="replace" and it results in xml validate error as well.

Elephante, Sean Samborski
on 4/11/14, 3:02 AM

Thank you for your help so far. I have added what you say, but still getting an xml validation error. I truly don't understand what this problem is. I have added a screenshot to my question. Perhaps there is something else I am missing that is causing this.

Elephante, Sean Samborski
on 4/11/14, 3:38 AM

I believe this does it. Thanks for your help.

Elephante, Sean Samborski
on 4/11/14, 5:57 AM
2

Nehal

--Nehal--
2090
| 5 2 8
Ahmadabad, India
--Nehal--
Nehal
On 4/10/14, 6:37 AM

Hi,

Try the following:

<record id="hr_contract_form_inherited_view_new" model="ir.ui.view">
    <field name="name">hr.contract.form.inherited.new</field>
    <field name="model">hr.employee</field>
    <field name="priority">17</field>
    <field name="inherit_id" ref="hr_contract.hr_hr_employee_view_form2"/>
    <field name="arch" type="xml">
        <field name="children" position="replace">
                 <field name="children" invisible="1"/>
        </field>                   
    </field> </record>

also put "hr_contract" in _openerp_.py as depedent module.

ValidateError

Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

Elephante, Sean Samborski
on 4/10/14, 1:14 PM

I get the above error when I try your method in the view. Maybe I have an incorrect setting somewhere?

Elephante, Sean Samborski
on 4/10/14, 1:15 PM

I have edited my answer. Hope this will solve your issue.

Nehal
on 4/11/14, 2:56 AM

I'm only using this in an extended view. I haven't mastered the delicate art of creating a module that doesn't return the "No handler found" error. So for now this is only in a view. I think the problem I have found is the group this field is in. Since I'm hiding all the fields in group name="contract" I think it's not liking it. How do you hide a group? I've tried position="replace" and it results in xml validate error as well.

Elephante, Sean Samborski
on 4/11/14, 3:03 AM
1
GG
On 4/10/14, 7:31 AM

Hi Sean

<field name="name"  position="attributes">
    <attribute name="invisible">True</attribute>
</field>

Hope this helps !

ValidateError

Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

Elephante, Sean Samborski
on 4/10/14, 1:14 PM

I get the above error when I try your method in the view. Maybe I have an incorrect setting somewhere?

Elephante, Sean Samborski
on 4/10/14, 1:15 PM

I'm only using this in an extended view. I haven't mastered the delicate art of creating a module that doesn't return the "No handler found" error. So for now this is only in a view. I think the problem I have found is the group this field is in. Since I'm hiding all the fields in group name="contract" I think it's not liking it. How do you hide a group? I've tried position="replace" and it results in xml validate error as well.

Elephante, Sean Samborski
on 4/11/14, 3:03 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/10/14, 6:27 AM
Seen: 1789 times
Last updated: 3/16/15, 8:10 AM