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