如何在库存移动树中显示类别。这是我的编码。
我的视图文件。
<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()任何帮助都是非常感谢的。
发布于 2014-02-18 08:48:13
试试这些文件。
您的.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>
在此之后,请查看您的股票移动树视图。
https://stackoverflow.com/questions/21847558
复制相似问题