Skip to Content
Menu
This question has been flagged
1 Reply
9393 Views

My program

class ProjectTask(models.Model):

    _inherit = "project.task"

class AccountAnalyticLine(models.Model):

    _inherit = 'account.analytic.line'

     employee_id = fields.Many2one('hr.employee', string="Employee")

xml

<xpath expr="//page/field[@name='timesheet_ids']/tree/field[@name='user_id']" position="after">

                        <field name="employee_id"/>  

 </xpath>

Notes

I inherited the view and add the above but I get an error external id not found.Please help me how to solve this issue. Thanks in advance



Avatar
Discard

The field you are trying to change is not in viewtaskform2

please try this :

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

<field name="name">employee taks form</field>

<field name="model">project.task</field>

<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited"/>

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

<xpath expr="//notebook/page/field[@name='timesheet_ids']/tree/field[@name='user_id']" position="after">

<field name="employee_id"/>

</xpath>

</field>

</record>

Best Answer

hello,

here is an example to add a field to sale order line :

py file

_inherit = 'sale.order.line'

my_field = fields.Many2one('some.class', string="Any Name")


xml file

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

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

            <field name="model">sale.order</field>

            <field name="inherit_id" ref="sale.view_order_form"/>

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

                <xpath expr="//notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="after">

                    <field name="my_field"/>

                </xpath>

            </field>

        </record>

Hope this helps.If you need more help, please post your code.

Avatar
Discard
Author

Thanks amal. But I use my code like this.But I didn't get.Here is xml code

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

<field name="name">employee taks form</field>

<field name="model">project.task</field>

<field name="inherit_id" ref="project.view_task_form2"/>

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

Author

<xpath expr="//notebook/page/field[@name='timesheet_ids']/tree/field[@name='user_id']" position="after">

<field name="employee_id"/>

</xpath>

</field>

</record>

Author

amal get anything clue?

Author

Thanks amal this is my mistake.my view id is wrong.The one2many is inherited.so I didn't notice that.this is corroct id

<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited"/>

Related Posts Replies Views Activity
1
May 17
3558
1
Sep 22
1009
4
May 18
9448
0
Mar 23
3773
2
Mar 22
7902