问题
I am getting current login user id by following function
def _get_user_name(self, cr, uid, *args):
user_obj = self.pool.get('res.users')
user_value = user_obj.browse(cr, uid, uid)
return user_value.id or False
and now i want to use its value in this field's Domain like ....
x_trainer_id = fields.Many2one('res.partner', string='Trainer',domain=[('user_id.id','=','get_user_name')])
How is it possible? I'll be very thankful....
回答1:
you can do it as below:
x_trainer_id = fields.Many2one('res.partner', string='Trainer',domain=lambda self: [('id', '=', self.env.uid)])
pass domain=lambda self: [('id', '=', self.env.uid)]
来源:https://stackoverflow.com/questions/37618187/how-can-i-use-function-value-in-domain-filter