2017-06-05 43 views
0

我想USER_IDdef read选择hr.employee 7

领域选择hr.employee自动为:

'tested_by':fields.many2one("hr.employee",string="Tested by"), 

回答

0

您需要使用_defaults

def _get_employee(self, cr, uid, context=None): 
    res = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=c) 
    return res and res[0] or False 

_columns = { 
    'tested_by':fields.many2one("hr.employee",string="Tested by"), 
} 

_defaults = { 
    'tested_by': _get_employee, 
} 
+0

谢谢你的答案,这是有帮助的 – Bobbi