Skip to Content
Menu
This question has been flagged
2 Replies
25419 Views

Hi group.

I am new to Odoo.

I was able to add a new  field in hr.view_employee_form, adding value and saving it.

    <record model="ir.ui.view" id="hr_test_att">
            <field name="name">hr_test_att</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>

            <field name="arch" type="xml">
                <field name="barcode" position="before">
                    <field name="bio_id"/>
                </field>
            </field>

        </record>

but viewing employee kanban view using other user other then admin gives an error of

ValueError: Element '<field name="barcode">' cannot be located in parent view

Error context:
View `hr_test_att`
[view_id: 2361, xml_id: hr_test_att.hr_test_att, model: hr.employee, parent_id: 329]



class hr_test_att(models.Model):
_inherit = 'hr.employee'

bio_id = fields.Integer('Bio id')

def _default_employee(self):
return self.env['hr.employee'].search([('bio_id', '=', self.env.uid)], limit=1)


Can someone point me to the right direction?.

thank you.


Avatar
Discard
Best Answer
<record id="hr_test_att" model="ir.ui.view">
<field name="name">hr_test_att.</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='barcode']" position="before">
<field name="bio_id" />
</xpath>
</field>
</record>
  • Try using xpath .

  • Check the given ref is correct .

  • Don't forget to add hr in depends in manifest file .

Avatar
Discard
Best Answer

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

<field name="name">hr_test_att.</field>

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

<field name="inherit_id" ref="hr.view_employee_form" />

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

<xpath expr="//field[@name='barcode']" position="after">

<field name="bio_id" />

</xpath>

</field>

</record>


we have to provide  xpath,

to add field in exiting value which you have forgotten.

put hr in manifest depends section too. 


Regards


MUHAMMAD IMRAN
Technical and Functional Consultant  (ODOO)


Softtar Technologies Pvt. Ltd. Contact : Pakistan (+92)-3037701373
 
Address  Allhafeez Shopping Mall
Lahore
Pakistan  (Branch Office)
http://sofftar.com
Avatar
Discard