Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
10338 Vues

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
Ignorer

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>

Meilleure réponse

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
Ignorer
Auteur

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">

Auteur

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

<field name="employee_id"/>

</xpath>

</field>

</record>

Auteur

amal get anything clue?

Auteur

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"/>

Publications associées Réponses Vues Activité
1
mai 17
4154
1
sept. 22
2126
4
mai 18
10983
0
mars 23
5024
2
mars 22
9494