diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py
index d6c06caed..25b77f17a 100644
--- a/yuthon_holiday/models/inherit_hr_leave.py
+++ b/yuthon_holiday/models/inherit_hr_leave.py
@@ -148,6 +148,12 @@ class HrLeave(models.Model):
('22', '22:00'), ('22.5', '22:30'),
('23', '23:00'), ('23.5', '23:30')], string='结束时间')
+ def update_state(self):
+ leave_ids = self.env["hr.leave"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for leave in leave_ids:
+ leave.state = 'draft'
+
@api.model
def create(self, vals):
allocation = super(HrLeave, self).create(vals)
@@ -201,7 +207,7 @@ class HrLeave(models.Model):
self.env['vacation.over.line'].create({
'vacation_id': reports_id.id,
'employee_id': employee.id,
- 'update_type': 'add',
+ 'update_type': 'reduce',
'workday': allocation.number_of_days * 8,
'legal_day': 0,
'public_holidays': 0,
diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py
index b73e31872..8c7e107ac 100644
--- a/yuthon_holiday/models/inherit_hr_leave_allocation.py
+++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py
@@ -106,11 +106,11 @@ class HrLeaveAllocation(models.Model):
@api.model
def create(self, vals):
allocation = super(HrLeaveAllocation, self).create(vals)
+ employee = allocation.employee_id
+ hours = allocation.number_of_hours_display
if allocation.holiday_status_id.name == '年假' and allocation.state == 'validate':
- employee = allocation.employee_id
- days = allocation.number_of_hours_display
employee.write({
- 'quota_issued': employee.quota_issued + days
+ 'quota_issued': employee.quota_issued + hours
})
reports_id = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', employee.id)
@@ -120,10 +120,24 @@ class HrLeaveAllocation(models.Model):
'vacation_id': reports_id.id,
'update_type': 'add',
'update_date': fields.Datetime.now(),
- 'update_lines': days,
+ 'update_lines': hours,
'allocation_type': 'allocation',
'text': allocation.name
})
+ elif allocation.holiday_status_id.name == '补休':
+ reports_id = self.env['yuthon.vacation.reports'].search([
+ ('employee_id', '=', employee.id)
+ ], limit=1)
+ self.env['vacation.over.line'].create({
+ 'vacation_id': reports_id.id,
+ 'update_type': 'add',
+ 'update_date': fields.Datetime.now(),
+ 'workday': hours,
+ 'legal_day': 0,
+ 'public_holidays': 0,
+ 'meal_number': 0,
+ 'text': allocation.name
+ })
return allocation
def unlink(self):
@@ -132,20 +146,33 @@ class HrLeaveAllocation(models.Model):
# 检查是否有需要同步的员工记录
if record.employee_id and record.holiday_status_id.name == '年假':
employee = record.employee_id
- days = record.number_of_hours_display
+ hours = record.number_of_hours_display
lines_to_delete = self.env['vacation.leave.line'].search([
('vacation_id.employee_id', '=', employee.id),
('update_type', '=', 'add'),
- ('update_lines', '=', days),
+ ('update_lines', '=', hours),
('allocation_type', '=', 'allocation'),
('text', '=', record.name)
])
if lines_to_delete:
lines_to_delete.is_void = True
employee.write({
- 'quota_issued': employee.quota_issued - days
+ 'quota_issued': employee.quota_issued - hours
})
- return super(HrLeaveAllocation, self).unlink()
+ elif record.employee_id and record.holiday_status_id.name == '补休':
+ employee = record.employee_id
+ hours = record.number_of_hours_display
+ lines_to_delete = self.env['vacation.over.line'].search([
+ ('vacation_id.employee_id', '=', employee.id),
+ ('update_type', '=', 'add'),
+ ('workday', '=', hours),
+ ('text', '=', record.name)
+ ])
+ if lines_to_delete:
+ lines_to_delete.is_void = True
+
+ return super(HrLeaveAllocation, self).unlink()
+
def update_vacation(self):
leave_ids = self.env["hr.leave.allocation"].browse(
diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py
index 1460b55fc..14f4ca568 100644
--- a/yuthon_holiday/models/yuthon_vacation_reports.py
+++ b/yuthon_holiday/models/yuthon_vacation_reports.py
@@ -18,6 +18,22 @@ class YuthonVacationReports(models.Model):
working_overtime = fields.Float(string='加班时', compute='_compute_working_overtime', store=True)
meal_fee = fields.Integer(string="误餐次数", compute='_compute_meal_fee', store=True)
+ def overtime_allocation(self):
+ form_id = self.env.ref('hr_holidays.hr_leave_allocation_view_form_manager').id
+ holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '补休')])
+ return {
+ 'name': '补休时分配',
+ 'view_mode': 'form',
+ 'res_model': 'hr.leave.allocation',
+ 'type': 'ir.actions.act_window',
+ 'views': [(form_id, 'form')],
+ 'context': {
+ 'default_holiday_status_id': holiday_status_id.id,
+ 'default_employee_ids': [(6, 0, [self.employee_id.id])],
+ 'default_allocation_type': 'regular',
+ 'default_name': '补休增加',
+ }}
+
def update_vac(self):
vacation_ids = self.env["yuthon.vacation.reports"].browse(
self._context.get('active_ids', self._context.get('active_id')))
diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml
index 051b08425..47321f615 100644
--- a/yuthon_holiday/views/hr_leave_batch.xml
+++ b/yuthon_holiday/views/hr_leave_batch.xml
@@ -215,7 +215,13 @@
[('employee_id.user_id', '=', uid)]
-
+
+ 初始化状态
+
+
+ code
+ action = model.update_state()
+