Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
24806 Vizualizări

i'm trying to replace a field in a treeview ... help me please

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

<field name="name">project.task.form.inherited</field>

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

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

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

<field name="project_id" position="attributes">

<attribute name="on_change">onchange_project(project_id)</attribute>

</field>

<field name="tag_ids" position="after">

<field name="analytic_account_id" invisible="1"/>

<field name="progress" widget="progressbar"

groups="project.group_time_work_estimation_tasks"/>

</field>

<xpath expr="//notebook/page[@name='description_page']" position="after">

<page string="Timesheets" groups="project.group_tasks_work_on_tasks,project.group_time_work_estimation_tasks">

<field name="timesheet_ids" groups="project.group_tasks_work_on_tasks" context="{'default_account_id' : analytic_account_id, 'default_is_timesheet' : 1}">

<tree editable="top" string="Timesheet Activities">

<field name="date"/>

<field name="user_id" required="1"/>

<field name="name"/>

<field name="account_id"/>

<field name="unit_amount" string="Duration" sum="Total time" widget="float_time"/>

<field name="is_timesheet" invisible="1"/>

</tree>

</field>

<group>

<group class="oe_subtotal_footer oe_right" name="project_hours" groups="project.group_time_work_estimation_tasks">

<field name="effective_hours" widget="float_time" groups="project.group_time_work_estimation_tasks"/>

<field name="remaining_hours" widget="float_time" class="oe_subtotal_footer_separator" groups="project.group_time_work_estimation_tasks"/>

</group>

</group>

</page>

</xpath>

</field>

</record>


i want add new field inside "timesheet_ids", 

this is my custom script on _view.xml


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

<field name="name">project.task.view.form</field>

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

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

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

<xpath expr="/notebook/page[@name='description_page']" position="before">

<page string="Timesheets" groups="project.group_tasks_work_on_tasks,project.group_time_work_estimation_tasks">

<field name="timesheet_ids" groups="project.group_tasks_work_on_tasks" context="{'default_account_id' : analytic_account_id, 'default_is_timesheet' : 1}">

<tree editable="top" string="Timesheet Activities">

<field name="date"/>

<field name="user_id" required="1"/>

<field name="name"/>

<field name="unit_amount" string="Duration" sum="Total time" widget="float_time"/>

<field name="is_timesheet" invisible="1"/>

<field name="invoiceable_analytic_line"/>

</tree>

</field>

</page>

</xpath>

</field>

</record>


but it's not work, why ? please help me and give me solution

Thanks


Aziz Adi Nugroho from Indonesia

Imagine profil
Abandonează
Cel mai bun răspuns

You can add a new field in tree view usig view inheritance. The purpose of inheritance or why we need inheritance is given below:

  1. To change attributes of some fields which exists on existing/custom model (e.g. making fields readonly,invisible)

  2. To add/modify/delete old or new fields in existing/custom model (e.g. Product, Sales, HR, Fleet Management, Attendance modules model etc)

  3. We can also add buttons in already existing/custom model (form and tree) view by using inheritance

Get complete code of view and model inheritance: http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Imagine profil
Abandonează

To add new field in tree view you need to inherit tree view of parent view:

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

Thanks

Cel mai bun răspuns

Hi Aziz, are you interested to become one of our team in Indonesia?

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

please try this code

<xpath expr="//notebook/page[@string='Timesheets']/

timesheet_ids/tree/field[@name="is_timesheet"]" position="after">

<field name="invoiceable_analytic_line"/>

</xpath>

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
mar. 15
5914
2
dec. 22
7843
1
sept. 15
4786
2
mar. 24
1752
2
mai 21
3051