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

How to define correct XPath location ? [Closed]

By
priyankahdp
on 3/18/13, 8:33 AM 11,902 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/18/2013 04:51:38

I was set ssnid & sinid as invisible fields.but both are still shows in my view.seems issue with XPath location.!

<xpath expr="/form/notebook/page/group/field[@name='ssnid']"

Anyone can help me to sort out ?

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- 1st part of the sim_view start -->
        <record model="ir.ui.view" id="madulsima_plucker_form">
            <field name="name">madulsima.plucker.form</field>
            <field name="model">madulsima.plucker</field>
            <field name="inherit_id" ref="hr.view_employee_form" />
            <field name="type">form</field>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Madulsima Plucker Fields">
                        <field name="reg_no" />
                        <field name="worker_name" />

                        <xpath expr="/form/notebook/page/group/field[@name='ssnid']"
                            position="attributes">
                            <attribute name="invisible">True</attribute>
                        </xpath>
                        <xpath expr="/form/notebook/page/group/field[@name='sinid']"
                            position="attributes">
                            <attribute name="invisible">True</attribute>
                        </xpath>

                    </page>
                </notebook>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_plucker_registration">
            <field name="name">Plucker Registration</field>
            <field name="res_model">madulsima.plucker</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
        </record>


        <menuitem id="menu_madulsima_plucker" name="Madulsima/Checkroll" />

        <menuitem id="menu_madulsima_plucker_registration" name="Plucker Registration"
            parent="menu_madulsima_plucker" action="action_plucker_registration" />
    </data>
</openerp>

i posted my whole code in view.xml

here is my class

from openerp.osv import fields, osv
import random

class madulsima_plucker(osv.osv):
    _name = "madulsima.plucker"
    _description = "This table is for keeping personal data of madulsima pluckers"
    _inherit = "hr.employee"
    _columns = {
        'reg_no': fields.char('Registration Number', size=256, required=True),
        'worker_name': fields.char('Worker Name', size=256, required=True)
    }

madulsima_plucker()

when you want to display error's log, display on ly last 15 lines, it' suffisant generally. bye

Cyril Gaspard (GEM)
on 3/18/13, 10:17 AM
2

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 3/18/13, 8:55 AM
<record model="ir.ui.view" id="madulsima_repace_hr_form">
    <field name="name">madulsima.replace.hr.form</field>
    <field name="model">hr.employee</field>
    <field name="inherit_id" ref="hr.view_employee_form" />
    <field name="type">form</field>
    <field name="arch" type="xml">
        <xpath expr="/form/notebook/page/group/field[@name='ssnid']" position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
        <xpath expr="/form/notebook/page/group/field[@name='sinid']" position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
    </field>
</record>

error updated in my post please check it

priyankahdp
on 3/18/13, 9:26 AM

you must use model hr.employee : <field name="model">hr.employee</field> and I do a bad copy/cut in my previous answer, sorry. Should work now. Bye

Cyril Gaspard (GEM)
on 3/18/13, 9:48 AM

I used this code in my module.here shows to change hr.employee model.?

<field name="model">hr.employee</field>

can i place my table name instead of hr.employee ?

error still same friend

priyankahdp
on 3/18/13, 10:37 AM

I can''t say you if you can replace model hr.employee by yours because I don't know if your class madulsima.plucker inherit of hr.employee, if it the case you can and use code done by Sudhir. I give the code where I was sure it's work, that's why I do not add your own new notebook and fields. I you have an error with my code, verify fields are present in module hr, if present, verify you have not an other module which inherit on the view_employee_form, if this is the case, you must inherit on the last inherited viiew (in case where there is attribute replace/attributes in this view). Bye

Cyril Gaspard (GEM)
on 3/18/13, 11:23 AM

added my model class to post

priyankahdp
on 3/18/13, 11:26 AM

version openrp (always give it because code change sometimes between version. Bye

Cyril Gaspard (GEM)
on 3/18/13, 11:41 AM

do you want to create a new objet with your class or just add/hide fields in existant view hr employee ?

Cyril Gaspard (GEM)
on 3/18/13, 11:44 AM

I need to create a my own worker class.need to inherit some fields from hr.employee class & not need some fields.thats why i asked for "how to hide them"

priyankahdp
on 3/18/13, 2:08 PM

when all informations are done, answer can be better, less time spend, for next question try to give all this informations not just the xml file, give also each time openerp version you are using. Last answer : copy paste view_employee_form in your xml file, rename name and id of the view, use your model name class, rmove or add fiels you want, verify you have all fields and class inherited or present in your python file, all import in the head of python file, and class required called in hr employee python file, restart openerp server to be sure, upgrade your module . Bye

Cyril Gaspard (GEM)
on 3/18/13, 2:56 PM

read comment before too, in your case in the view, you do not need line inherit in definition of your view, because this is a new view, inherit in python is here to have all its fields and method. bye

Cyril Gaspard (GEM)
on 3/18/13, 3:01 PM
4

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 3/18/13, 11:00 AM

Try this it will work.

<field name="arch" type="xml">
        <notebook position="inside">
            <page string="Madulsima Plucker Fields">
                <field name="reg_no" />
                <field name="worker_name" />
            </page>
        </notebook>
        <xpath expr="/form/notebook/page/group/field[@name='ssnid']"  position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
        <xpath expr="/form/notebook/page/group/field[@name='sinid']" position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
</field>

You can refer [Inheritance in View]. (http://doc.openerp.com/v6.0/developer/2_6_views_events/views/view_inheritence.html)

This will help you lot.

thanks Sudhir ..no errors occured but still ssnid & sinid shows in my view

priyankahdp
on 3/18/13, 11:23 AM

Check for the view which is loading, standard or the form you created by inheriting , i think it is loading the standard view

Maniganda
on 4/24/13, 3:46 AM

thanks Maniganda :-)

priyankahdp
on 4/24/13, 3:52 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 3/18/13, 8:33 AM
Seen: 11902 times
Last updated: 3/16/15, 8:10 AM