コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3811 ビュー

department_id = fields.Many2one('hr.department', string='Dział', required=True, track_visibility='onchange', store=True)

employee_id = fields.Many2many('hr.employee', 'department_id', index=True)


 @api.depends('department_id')

@api.onchange('department_id')

def _compute_employees(self):

emp_data = self.env['hr.employee'].browse([('department_id','in',self.department_id.id)])

for department in self:

department.employee_id = emp_data    


Don't work...



アバター
破棄
最善の回答

Hai Michal,

    Just make a small change in your onchange function.


    @api.onchange('department_ids')
    def get_employee(self):
        if self.department_ids: 
            self.employee_ids = self.env['hr.employee'].search([('department_id','=',self.department_ids.id)])

It will work for you.

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 22
2290
0
11月 22
2564
0
6月 22
1822
2
3月 20
4480
1
8月 25
2011