user3454343
user3454343

Reputation: 21

Openerp. How to retrieve data using fields.function?

This is my piece of code. I can't understand how to retrieve data from columns in case if column private is equal to 't' ( True ). I know that I should use fields.function but i can't understand what to do exactly. Can someone show me an example?

    _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),


    }

Upvotes: 0

Views: 237

Answers (1)

Yaseen Shareef
Yaseen Shareef

Reputation: 767

According to your question, you need to access the data in other columns using fields.function. This can be done by browsing through the desired model in the function that you use in the functional field. The follwong is an example:

'your_field': fields.function(your_function,type='float',method=True,string='Your string'),

And then in 'your_function', you can use browse() to retrieve the data of the desired model. I hope this solves your problem

Upvotes: 1

Related Questions