2016-05-17 14 views
0

フィールドをツリービューで置き換えようとしています。お願い助けて。ツリービューで新しいフィールドを追加する方法(継承して継承する)

これは、これが_view.xmlに私のカスタムスクリプトであるベースodooのentepriceに

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

スクリプトです:

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

私は"timesheet_ids"の内側に新しいフィールド"invoiceable_analytic_line"を追加したいが、それは動作しません。 。

誰か助けてください?

ありがとうございました。

+1

invoiceable_analytic_lineがone2many分野である??たいあなたのフィールドを挿入 – prakash

+0

project.view_task_form2の代わりにmodule_of_view.view_task_form2_inheritedを継承する必要があります(そのビューを追加するモジュールの名前はビューの変更)。 プラス私はすべてその式のこのINSEADを行うすることをお勧めいたします: <フィールド名=「is_timesheet」位置=「の後に」> <フィールド名=「invoiceable_analytic_line」/> これは、あなたに十分でなければなりませんあなたが必要とするものを表示する。 – dccdany

答えて

0


ビュー
手順が正しいですが、のxpath内部exprの属性を持つエラーがあるだけのこと。代わりに

<xpath expr="/notebook/page[@name='description_page']" position="replace">
あなたが書く必要があります:description_pageは
存在しないのでodoo 10
<xpath expr="/sheet/notebook/page[@string='Description']" position="replace">
にそう/project/project_view.xmlから全体<page string="Description">..</page>タグをコピーする際に
<xpath expr="//sheet/notebook/page[1]" position="replace">
を文字列を変更してxpathタグ​​の中に貼り付けます。その後あなたが

モデル

class Add_in_timesheet(models.Model) 
    _inherit = 'project.task 
    invoiceable_analytic_line = fields.Char(string=u"Invoiceable") 

picture from odoo8/addons/project/project_view.xml

関連する問題