2017-10-11 63 views
2

我试图在xml上显示该字段。但是,问题是?它没有显示的字段。这里是我的代码:odoo xml无法显示字段

xml file. 

<tr> 
    <td class="bottom_border_only" ><span t-field="o.test_field_function"/></td> 
</tr> 

Python文件

def test_function(self,cr,uid,ids,origin, args, context=None) : 
    print "success" 

'test_field_function' : fields.function(test_function, method=True, string='data_po', type='char', store=True), 
+0

喜@斯嘉丽石,你的函数不返回值,并且你已经问过同样的问题,https://stackoverflow.com/questions/46644444/how-to-call-a-method-in-odoo-7/46645162#46645162 –

回答

1

你的领域将永远不会有一个值,你声明的方式。在函数中,您需要设置我使用手机的字段的值,但是在新的API中,函数应该是这样的。

@depends('some_field') 
    def test_function(self) : 
     for rec in self: 
      # loop because self can have more than one record 
      rec. test_field_function = "success" 

打印的消息将只打印到标准输出女巫是控制台检查odoo代码来看看如何使用计算字段有很多是开源的,你由专业人员FINF优雅的代码书写

+0

你的代码使用odoo 8版本,我使用odoo 7版本 –

+0

你可以参考这个答案从odoo论坛: https://www.odoo.com/forum/help-1/question/openerp-fields-function-explanation -13118 这可能对您的情况有所帮助 –