2016-11-24 48 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