Python 开场白。如何使用fields.function检索数据?

Python 开场白。如何使用fields.function检索数据?,python,openerp,Python,Openerp,这是我的代码。如果列private等于“t”(True),我无法理解如何从列中检索数据。我知道我应该使用fields.function,但我不知道该怎么做。有人能给我举个例子吗 _columns = { 'created_by' : fields.many2one('res.users', 'Author', readonly=True), 'name': fields.char('Name', required=True),

这是我的代码。如果列private等于“t”(True),我无法理解如何从列中检索数据。我知道我应该使用fields.function,但我不知道该怎么做。有人能给我举个例子吗

    _columns = {
            'created_by' : fields.many2one('res.users', 'Author', readonly=True),
            'name': fields.char('Name', required=True),
            'state': fields.selection(crm.AVAILABLE_STATES, 'State', select=True, track_visibility='onchange'),
            'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True , track_visibility='onchange'),
            'description': fields.text('Description', required=1),
            'private': fields.boolean('Private'),
            'contract':fields.many2one('account.analytic.account', 'Analytic account', track_visibility='onchange'),
            'partner_id': fields.many2many('res.users', ),
            'deadline': fields.date('Deadline', track_visibility='onchange'),
            'create_date': fields.date('Create_date', readonly=True),


    }

根据您的问题,您需要使用fields.function访问其他列中的数据。这可以通过浏览功能字段中使用的功能中所需的模型来完成。以下是一个例子:

'your_field': fields.function(your_function,type='float',method=True,string='Your string'),
然后在“your_function”中,可以使用browse()检索所需模型的数据。我希望这能解决你的问题