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

Element not found in parent view [SOLVED]

By
dirtyHandsPHP
on 8/12/14, 7:08 AM 5,825 views

I want to remove a group from HR Settings section using my customized module.

Section to be removed in hr.view_employee_form has been added by hr_holidays_view.xml using inheritance

hr_view.xml(view_employee_form form)

<page string="HR Settings" groups="base.group_hr_user">
           <group>
                       <group string="Active" name="active_group">
                                <field name="active"/>
                         </group>
            </group>

 </page>

Code added by hr_holidays_view.xml

 <xpath expr="//group[@name='active_group']" position="before">
          <group string="Leaves">
                   <label for="remaining_leaves"/>
                        <div>
                            <field name="remaining_leaves" class="oe_inline"/> days
                        </div>
           </group>
  </xpath>

 

Code written by me to remove that Remaining Leaves block, in my customized module is :

<xpath expr="/form/sheet/notebook/page[@string='HR Settings']/group/group[@string='Leaves']" position="replace">

</xpath>

and I am getting following error:

 

AttributeError: View definition error for inherited view 'custom_emp.emp_code_view_form' on model 'hr.employee': Element '<xpath expr="/form/sheet/notebook/page[@string='HR Settings']/group/group[@string='Leaves']">' not found in parent view 'hr.view_employee_form'

Please help!

 

Updated Full Code :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!--Employee form view -->
        <record id="emp_code_view_form" model="ir.ui.view">
            <field name="name">hr.employee.form.inherit</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form" />
            <field name="arch" type="xml">
                <xpath expr="/form/sheet/notebook/page[@string='HR Settings']/group/group[@string='Leaves']" position="replace">
                </xpath>
                <xpath expr="/form/sheet/notebook/page[@string='HR Settings']/group/group[@string='Active']/field[@name='active']" position="after"
                         <field name="working_status" />
                </xpath>
             </field>
        </record>
     </data>
</openerp>

 

Update: Above code is working well on one machine but not other one!!

I have tried <xpath expr="//group[@string='Leaves']" position="replace"> code as well....but no success

dirtyHandsPHP
on 8/12/14, 7:11 AM

Please post your complete custom view declaration.

René Schuster
on 8/12/14, 7:52 AM

Code has been updated....2nd xpath tags are working well....

dirtyHandsPHP
on 8/12/14, 8:07 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 8/12/14, 9:50 AM

Hi,

You can solve this issue by two way.

1) Just write down the inheritance as like below.

        <record id="view_employee_form_leave_inherit_to_remove_leaves" model="ir.ui.view">
            <field name="name">hr.employee.leave.form.inherit</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr_holidays.view_employee_form_leave_inherit"/>
            <field name="arch" type="xml">
                <xpath expr="//group[@string='Leaves']" position="replace">
                </xpath>
            </field>
        </record>

 

2) Override the view of the hr_holidays like below.

        <record id="hr_holidays.view_employee_form_leave_inherit" model="ir.ui.view">
            <field name="name">hr.employee.leave.form.inherit</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <xpath expr="//group[@name='active_group']" position="before">
                </xpath>
                <xpath expr="//div[@name='button_box']" position="inside">
                    <button name="%(act_hr_employee_holiday_request)d" string="Leaves" type="action" groups="base.group_hr_user"/>
                </xpath>
            </field>
        </record>

 

Hi, I have tested it in my local system. It is working perfectly. So, just try it and mark my answer with your vote.

Emipro Technologies Pvt. Ltd.
on 8/12/14, 9:51 AM

@Chirag : Much thanks dude.......I opted first one and it worked!!! Thumbs up!!!

dirtyHandsPHP
on 8/13/14, 2:52 AM
1

Vasiliy Birukov

--Vasiliy Birukov--
3446
| 6 6 8
Russian Federation
--Vasiliy Birukov--

Help develop and implement any project on base Odoo.

Vasiliy Birukov
On 8/12/14, 7:22 AM

Are you apply inheritance to inherited view?

yes

dirtyHandsPHP
on 8/12/14, 7:34 AM

But Error point to parent view. Please post full your record.

Vasiliy Birukov
on 8/12/14, 7:57 AM

Code has been updated.....please check

dirtyHandsPHP
on 8/12/14, 8:07 AM
change reference on inhereted view!
Vasiliy Birukov
on 8/12/14, 8:41 AM

field name="inherit_id" ref="hr.view_employee_form"

Vasiliy Birukov
on 8/12/14, 8:43 AM

It's already there

dirtyHandsPHP
on 8/12/14, 8:45 AM

must be (field name="inherit_id" ref="inhereted view from hr_holidays_view.xml")

Vasiliy Birukov
on 8/12/14, 8:53 AM

then how i will make changes in hr.view_employee_form?

dirtyHandsPHP
on 8/12/14, 8:55 AM

yes

Vasiliy Birukov
on 8/12/14, 9:01 AM

it will apply to new view (inhereted)

Vasiliy Birukov
on 8/12/14, 9:02 AM

That will be combination of parent view plus change

Vasiliy Birukov
on 8/12/14, 9:04 AM
0

René Schuster

--René Schuster--
1560
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 8/12/14, 8:15 AM

Change the inherit_id in your custom view to hr.employee.leave.form.inherit:

<field name="inherit_id" ref="hr.employee.leave.form.inherit"/>

 

Regards.

I can't do that because i am making changes in hr employee form view as well....you would have seen in my code that i have added working_status field as well using xpath

dirtyHandsPHP
on 8/12/14, 8:44 AM

Give it a try (or inherit both views.)

René Schuster
on 8/12/14, 8:51 AM

Can't do because it's not present in any form....it has been inherited to hr employee module

dirtyHandsPHP
on 8/12/14, 8:53 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

2 follower(s)

Stats

Asked: 8/12/14, 7:08 AM
Seen: 5825 times
Last updated: 3/16/15, 8:10 AM