@@ -850,14 +850,14 @@ class SoongWorkflowRecord(models.Model):
|
||||
local_time = current_utc_time + timedelta(hours=8)
|
||||
h = local_time.hour
|
||||
m = local_time.minute
|
||||
# if not (h == 17 and 25 <= m <= 35):
|
||||
# return
|
||||
if not (h == 17 and 25 <= m <= 35):
|
||||
return
|
||||
|
||||
menu_id = self.env['ir.ui.menu'].search([('name', '=', '待办流程')], limit=1)
|
||||
if not menu_id:
|
||||
return
|
||||
target_url = f'https://oa.thtzjt.com/web#action=4299&model=soong.workflow.record&view_type=list&cids=1-2-3-4&menu_id={menu_id.id}'
|
||||
active_employees = self.env['hr.employee'].search([('name', '=', '林思敏')])
|
||||
target_url = f'https://oa.thtzjt.com/web#aciton=4299&model=soong.workflow.record&view_type=list&cids=1-2-3-4&menu_id={menu_id.id}'
|
||||
active_employees = self.env['hr.employee'].search([('user_state', '=', 'in')])
|
||||
if not active_employees:
|
||||
return
|
||||
emp_to_user = {emp.id: emp.user_id.id for emp in active_employees if emp.user_id}
|
||||
|
||||
@@ -321,39 +321,6 @@ class YuthonVacationReports(models.Model):
|
||||
self.manage_reject()
|
||||
# ========== 第一步:处理年假逻辑 ==========
|
||||
for rec in self:
|
||||
current_date = rec.vacation_date
|
||||
current_year_first = fields.Date.to_date(f"{current_date.year}-01-01")
|
||||
# 找当前员工当年1月1日的报表主记录
|
||||
target_main_record = rec.env["yuthon.vacation.reports"].search([
|
||||
('employee_id', '=', rec.employee_id.id),
|
||||
('vacation_date', '=', current_year_first),
|
||||
], limit=1)
|
||||
# 提取需减额度
|
||||
leave_deduct = 0.0
|
||||
overtime_deduct = 0.0
|
||||
if target_main_record:
|
||||
# 年假需减值
|
||||
leave_lines = target_main_record.leave_ids.filtered(
|
||||
lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
leave_deduct = leave_lines.update_lines / 8 if (leave_lines and leave_lines.update_lines) else 0.0
|
||||
# 补休需减值
|
||||
overtime_lines = target_main_record.overtime_ids.filtered(
|
||||
lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
overtime_deduct = (overtime_lines.workday + overtime_lines.public_holidays) / 8 if (overtime_lines and overtime_lines.workday and overtime_lines.public_holidays) else 0.0
|
||||
|
||||
# 补休明细减值(仅过期时)
|
||||
if rec.valid_date1 and rec.valid_date1 < current_date and overtime_deduct > 0:
|
||||
self_overtime = rec.overtime_ids.filtered(
|
||||
lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
if self_overtime:
|
||||
self_overtime.workday = max(0.0, self_overtime.workday - overtime_deduct * 8)
|
||||
|
||||
# 年假明细减值(仅过期时)
|
||||
if rec.valid_date and rec.valid_date < current_date and leave_deduct > 0:
|
||||
self_leave = rec.leave_ids.filtered(lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
if self_leave:
|
||||
self_leave.update_lines = max(0.0, self_leave.update_lines - leave_deduct * 8)
|
||||
|
||||
valid_leave_lines = rec.leave_ids.filtered(
|
||||
lambda l: l.workflow_record_id and l.update_type == 'reduce' and l.is_void != True
|
||||
)
|
||||
@@ -410,6 +377,12 @@ class YuthonVacationReports(models.Model):
|
||||
rec.year_workday += workday_overtime_add
|
||||
rec.year_holiday += holidays_overtime_add
|
||||
|
||||
self_leave = rec.leave_ids.filtered(lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
self_leave.update_lines = (rec.dynamic_previous_year + rec.dynamic_remainder_year) * 8
|
||||
|
||||
self_overtime = rec.overtime_ids.filtered(lambda o: not o.workflow_record_id and o.text == '上月额度继承')
|
||||
self_overtime.workday = (rec.dynamic_previous_year1 + rec.this_year1) * 8
|
||||
|
||||
rec._compute_leave()
|
||||
rec._compute_meal_fee()
|
||||
rec._compute_working_overtime()
|
||||
@@ -1689,11 +1662,7 @@ class YuthonVacationReports(models.Model):
|
||||
('text', '=', '上月额度继承'),
|
||||
('text', '=', '年假分配')
|
||||
], limit=1)
|
||||
if existing_line:
|
||||
existing_line.write({
|
||||
'update_lines': number_of_hours_display,
|
||||
})
|
||||
else:
|
||||
if not existing_line:
|
||||
self.env['vacation.leave.line'].create({
|
||||
'vacation_id': report.id,
|
||||
'valid_date': report.valid_date1 + relativedelta(years=1) if report.valid_date1 else None,
|
||||
@@ -1713,11 +1682,7 @@ class YuthonVacationReports(models.Model):
|
||||
('vacation_id', '=', report.id),
|
||||
('text', '=', '上月额度继承'),
|
||||
], limit=1)
|
||||
if existing_line:
|
||||
existing_line.write({
|
||||
'workday': number_of_hours_display,
|
||||
})
|
||||
else:
|
||||
if not existing_line:
|
||||
if report.valid_date1 and report.dynamic_previous_year1 and not report.this_year1:
|
||||
valid_date = report.valid_date1
|
||||
elif report.valid_date1 and report.dynamic_previous_year1 and report.this_year1:
|
||||
|
||||
Reference in New Issue
Block a user