Files
gzth/yuthon_holiday/models/inherit_hr_leave_allocation.py
T
2024-10-21 17:46:52 +08:00

32 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
from odoo import models, fields, api
class HrLeaveAllocation(models.Model):
_inherit = 'hr.leave.allocation'
holiday_type = fields.Selection([
('employee', '按员工角色'),
('company', 'By Company'),
('department', 'By Department'),
('category', 'By Employee Tag')],
string='模式', readonly=False, required=True, default='employee')
users_role_ids = fields.Many2many('soong.user.role', string='角色范围')
new_employee_holidays = fields.Selection([('limit', '限制'), ('un_limit', '不限制')], string="新员工请假")
holiday_month = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 13)], string="入职月份", help='入职时长小于此月份时,不可申请此假期')
holiday_expiration_date = fields.Selection([('never', '永久'), ('no_never', '不固定')], string="新员工请假")
@api.onchange('users_role_ids')
def onchange_employee_ids(self):
users_role_list = []
for i in self.users_role_ids:
user_role_data = self.env['hr.employee'].search(['|', ('user_role_id', '=', i.id.origin), ('user_role_ids', '=', i.id.origin)])
users_role_list += [ro.user_id.id for ro in user_role_data]
if self.users_role_ids:
false_none_list = [x for x in users_role_list if x != False]
self.employee_ids = [(6, 0, list(set(false_none_list)))]