添加功能
This commit is contained in:
@@ -1121,19 +1121,25 @@ class YuthonVacationReports(models.Model):
|
||||
if att.is_abnormal: is_abnormal += 1
|
||||
|
||||
# 5. 计算应到天数(适配外派)
|
||||
# 取员工最早的合同(含已中止),从最早入职时间开始统计应到天数
|
||||
contract = self.env['hr.contract'].search([
|
||||
# 开始时间:取员工最早的合同(含已中止)的 date_start
|
||||
# 结束时间:取运行中(state='open')合同的 date_end
|
||||
earliest_contract = self.env['hr.contract'].search([
|
||||
('employee_id', '=', employee.id),
|
||||
], order='date_start asc, id asc', limit=1)
|
||||
running_contract = self.env['hr.contract'].search([
|
||||
('employee_id', '=', employee.id),
|
||||
('state', '=', 'open'),
|
||||
], order='date_end desc, id desc', limit=1)
|
||||
if is_outside:
|
||||
if exp_has_return and exp_end_return:
|
||||
work_days = rec._create_leave_record(employee, exp_end_return + timedelta(days=1), month_end)
|
||||
else:
|
||||
work_days = 0
|
||||
else:
|
||||
start_date = max(contract.date_start, month_start) if (
|
||||
contract and contract.date_start) else month_start
|
||||
end_date = min(contract.date_end, month_end) if (contract and contract.date_end) else month_end
|
||||
start_date = max(earliest_contract.date_start, month_start) if (
|
||||
earliest_contract and earliest_contract.date_start) else month_start
|
||||
end_date = min(running_contract.date_end, month_end) if (
|
||||
running_contract and running_contract.date_end) else month_end
|
||||
work_days = rec._create_leave_record(employee, start_date, end_date)
|
||||
|
||||
# 6. 计算试用期/转正天数
|
||||
|
||||
Reference in New Issue
Block a user