From e76ef5b7f079da6fc5ab28a575ec3f6945c4007d Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Sat, 14 Dec 2024 19:07:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/models/duty_approval.py | 1 - .../models/overtime_approval.py | 47 +------------------ .../views/yuthon_shift_approval_views.xml | 2 +- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/yuthon_hr_attendance/models/duty_approval.py b/yuthon_hr_attendance/models/duty_approval.py index ed1e90ca3..c0ad80b9e 100644 --- a/yuthon_hr_attendance/models/duty_approval.py +++ b/yuthon_hr_attendance/models/duty_approval.py @@ -20,7 +20,6 @@ class DutyApprovals(models.Model): reason_application = fields.Html(string="事由") related_issues_id = fields.Many2one('issue.library', string="关联议题") - @api.depends('date_start', 'date_end') def _compute_duration(self): for rec in self: diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 5797344ca..08be41f2d 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -14,7 +14,7 @@ class OvertimeApprovals(models.Model): name = fields.Char(string="标题", compute='_compute_name') code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('overtime_approval')) users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id) - overtime_approval_ids = fields.One2many('overtime.user.line', 'overtime_approval_id', string="加班审批行") + # overtime_approval_ids = fields.One2many('overtime.user.line', 'overtime_approval_id', string="加班审批行") reason_application = fields.Char(string="事由") department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门") is_issues = fields.Boolean(string='是否上会') @@ -138,51 +138,6 @@ class OvertimeApprovals(models.Model): class OvertimeUserLine(models.Model): _name = 'overtime.user.line' - _rec_name = 'overtime_approval_id' - _description = "加班明细行" - - overtime_approval_id = fields.Many2one('overtime.approval', string="加班单号") - users_id = fields.Many2one('res.users', string="加班人员") - department_id = fields.Many2one('hr.department', string="部门") - overtime_hours = fields.Float(string="本月加班时长") - start_time = fields.Datetime(string="开始时间") - end_time = fields.Datetime(string="结束时间") - hours = fields.Float(string="加班时长", compute="_compute_hours") - type_overtime = fields.Selection([('work', '工作日加班'), ('weekend', '周末加班'), ('holiday', '节假日加班')], - string="加班类型", compute="_compute_overtime_type") - - @api.depends('start_time', 'end_time') - def _compute_hours(self): - for record in self: - if record.start_time and record.end_time: - delta = record.end_time - record.start_time - record.hours = delta.total_seconds() / 3600 - else: - record.hours = 0 - - @api.depends('start_time', 'end_time') - def _compute_overtime_type(self): - for record in self: - if record.start_time and record.end_time: - if record.start_time > record.end_time: - raise UserError("开始时间不能晚于结束时间") - start_date = fields.Datetime.from_string(record.start_time) - end_date = fields.Datetime.from_string(record.end_time) - public_holidays = self.env['resource.calendar.leaves'].search([]) - for holiday in public_holidays: - holiday_start = fields.Datetime.from_string(holiday.date_from) - holiday_end = fields.Datetime.from_string(holiday.date_to) - if start_date <= holiday_end and end_date >= holiday_start: - record.type_overtime = 'holiday' - break - else: - if start_date.weekday() < 5 and end_date.weekday() < 5: # Not Saturday or Sunday - record.type_overtime = 'work' - elif start_date.weekday() >= 5 or end_date.weekday() >= 5: # Saturday or Sunday - record.type_overtime = 'weekend' - else: - record.type_overtime = False - # def is_holiday(self, date): # holiday_obj = self.env['resource.calendar.leaves'] diff --git a/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml b/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml index 928a0431c..66739d200 100644 --- a/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml +++ b/yuthon_hr_attendance/views/yuthon_shift_approval_views.xml @@ -43,7 +43,7 @@ - +