0

如何在库存移动树中显示类别。这是我的编码。

我的视图文件。

<record id="royalfood_stock_move_tree_view" model="ir.ui.view">
    <field name="name">stock.move.tree</field>
    <field name="model">stock.move</field>
    <field name="inherit_id" ref="stock.view_move_tree" />
    <field name="arch" type="xml"> 
              <xpath expr="//field[@name='product_id']" position="before">  
            <field name="categ_id" groups="base.group_user"/>   
              </xpath> 
    </field>
</record>

我的 .py 文件

class custom_stock_move_tree(osv.osv_memory):
_columns = {    
             'categ_id': fields.related('product_id', 'categ_id', type='many2one' ,relation='product.category', store=True),              
            }
custom_stock_move_tree()

任何帮助表示赞赏。

4

1 回答 1

0

试试这个文件。

你的.py文件

class custom_stock_move_tree(osv.Model): #their is different b/w osv.Model and osv.osv_memory before to use it read it's usage

    _inherit = 'stock.move' # if you want to add data in existing module use inherit  
    _columns = 
    {    
        'categ_id': fields.related('product_id', 'categ_id', type='many2one' ,relation='product.category', store=True, string='Product Category'),              
    }

您的view.xml文件

<record id="royalfood_stock_move_tree_view" model="ir.ui.view">
<field name="name">stock.move.tree</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree" />
<field name="arch" type="xml"> 
    <xpath expr="//field[@name='product_id']" position="before">  
        <field name="categ_id" groups="base.group_user"/>   
    </xpath> 
</field>

在此之后查看您的股票移动树视图。

于 2014-02-18T08:48:13.207 回答