2016-11-24 43 views
2

我添加了一個新的領域進入product_uom_categ模型,通過繼承這樣的:添加繼承場到樹視圖product_uom_categ - Odoo V9

class product_uom_categ(models.Model): 
    _inherit = 'product.uom.categ' 

    code_product = fields.Char(string="Código Unidad") 
在我看來

然後:

<openerp> 
<data> 
    <record id="product_uom_categ_form_view" model="ir.ui.view"> 
     <field name="name">product.uom.categ.form</field> 
     <field name="model">product.uom.categ</field> 
     <field name="inherit_id" ref="product.product_uom_categ_form_view" /> 
     <field name="arch" type="xml"> 
     <field name='name' position="after"> 
      <field name="code_product"/> 
     </field> 
     </field> 
    </record> 
</data> 
</openerp> 

它工作正常,儘管我想在該定義的樹視圖中看到這一點,但我找不到一種方法來實現它,例如,在原始視圖模型中,實際上並沒有定義樹視圖,而只是一個像這個:

<record id="product_uom_categ_form_view" model="ir.ui.view"> 
     <field name="name">product.uom.categ.form</field> 
     <field name="model">product.uom.categ</field> 
     <field name="arch" type="xml"> 
      <form string="Units of Measure categories"> 
       <group> 
        <field name="name"/> 
       </group> 
      </form> 
     </field> 
    </record> 
    <record id="product_uom_categ_form_action" model="ir.actions.act_window"> 
     <field name="name">Unit of Measure Categories</field> 
     <field name="type">ir.actions.act_window</field> 
     <field name="res_model">product.uom.categ</field> 
     <field name="view_type">form</field> 
     <field name="view_mode">tree,form</field> 
     <field name="help" type="html"> 
      <p class="oe_view_nocontent_create"> 
      Click to add a new unit of measure category. 
      </p><p> 
      Units of measure belonging to the same category can be 
      converted between each others. For example, in the category 
      <i>'Time'</i>, you will have the following units of measure: 
      Hours, Days. 
      </p> 
     </field> 
    </record> 

因此,在form它顯示了這兩個領域,name和我的新領域code_product,但樹視圖中,並沒有什麼,但也沒有什麼這方面的繼承,我應該繼承的行動?

我被困在這個,任何想法?

回答

1

你說得對。 product.uom.categ型號沒有樹形視圖。 Odoo使用name列生成默認樹視圖。

只需在您的[your_module]_views.xml文件中添加一個樹形視圖定義。

<record id="product_uom_categ_tree_view" model="ir.ui.view"> 
    <field name="name">product.uom.categ.tree</field> 
    <field name="model">product.uom.categ</field> 
    <field name="arch" type="xml"> 
     <tree string="Units of Measure categories"> 
      <field name="name"/> 
      <field name="code_product"/> 
     </tree> 
    </field> 
</record> 

希望它能解決你的問題。

+1

超級棒!非常感謝你!奇蹟般有效 :-) – NeoVe