【发布时间】:2015-04-07 16:57:01
【问题描述】:
我需要在树视图中显示 one2many 字段的值,所以我决定创建函数字段并在我的 xml 树视图中声明它:
def get_product_brands(self, cr, uid, ids, fields, arg, context):
res={}
for record in self.browse(cr, uid, ids, context=None).application_data_product_template_ids:
brands = record.brand.name or ''
print brands
res[record.id] = brands
return res
和我的字段声明:
'brands' : fields.function(get_product_brands, method=True, string="Product brands", type='char', store=True)
xml示例代码:
<record model="ir.ui.view" id="product_tree_inherit">
<field name="name">product.tree.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='categ_id']" position="after">
<field name="brands"/>
</xpath>
</field>
</record>
在我的控制台中,我可以看到打印的正确记录,但树视图中没有显示任何内容。
谁能帮帮我?
【问题讨论】: