From 8a927bd8f1a003e26ff6f43c375902fd0afc2515 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 5 Aug 2025 16:54:37 +0800 Subject: [PATCH 01/12] =?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 --- .../models/yuthon_vacation_reports.py | 101 +++++++++----- .../views/yuthon_vacation_reports_views.xml | 127 ++++++++++++++++-- .../views/hr_attendance_month_views.xml | 1 - yuthon_work_brand/views/hr_menus.xml | 12 +- 4 files changed, 192 insertions(+), 49 deletions(-) diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py index 8cf280782..9b814fff6 100644 --- a/yuthon_holiday/models/yuthon_vacation_reports.py +++ b/yuthon_holiday/models/yuthon_vacation_reports.py @@ -8,6 +8,7 @@ class YuthonVacationReports(models.Model): _name = 'yuthon.vacation.reports' _description = '假期额度记录' _rec_name = "employee_id" + _order = "vacation_date desc" employee_id = fields.Many2one('hr.employee', string='员工') department_id = fields.Many2one(related='employee_id.department_id', string="部门") @@ -19,10 +20,79 @@ class YuthonVacationReports(models.Model): other_fee_ids = fields.One2many('vacation.other.line', 'vacation_id', string='其他明细') vacation_date = fields.Date(string='日期', default=lambda self: fields.Date.today()) - leave = fields.Char(string='年假', compute='_compute_leave', store=True) + leave = fields.Char(string='年假', compute='_compute_leave', store=True, digits=(16, 3)) working_overtime = fields.Char(string='加班时', compute='_compute_working_overtime', store=True) meal_fee = fields.Integer(string="误餐次数", compute='_compute_meal_fee', store=True) medical_fee = fields.Float(string="体检费", compute='_compute_medical_fee', store=True) + compensatory_leave = fields.Integer(string="调休") + leave_of_absence = fields.Integer(string="事假", digits=(16, 3)) + statutory_leave = fields.Integer(string="法定假") + cop_leave = fields.Float(string='补休', digits=(16, 3)) + duty_off_leave = fields.Integer(string='值班调休') + marriage_leave = fields.Integer(string='婚假') + maternity_leave = fields.Integer(string='产假') + paternity_leave = fields.Integer(string='陪产假') + family_planning_leave = fields.Integer(string='计生假') + bereavement_leave = fields.Float(string='丧假') + home_visit_leave = fields.Integer(string='探亲假') + parents_meeting_leave = fields.Integer(string='家长会假') + general_sick_leave = fields.Float(string='病假(普通)') + hospital_sick_leave = fields.Float(string='病假(住院期)') + recovery_sick_leave = fields.Float(string='病假(出院恢复期)') + exam_leave = fields.Integer(string='考试假') + + come_late = fields.Integer(string="迟到") + is_early_card = fields.Integer(string="早退") + is_no_card = fields.Integer(string="缺卡") + is_work = fields.Integer(string='旷工') + vacation_state = fields.Selection( + selection=[ + ('unconfirmed', "未确认"), + ('confirmed', "已确认"), + ('pending', "待定"), + ], + string="状态", + readonly=True, copy=False, index=True, + tracking=3, + default='unconfirmed') + + def button_put(self): + menu_id = self.env['ir.ui.menu'].search([('name', '=', '考勤确认'), ('parent_id', '!=', False)]) + url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.attendance.month.detail&view_type=list&menu_id={menu_id.id}' + we_id = self.env['hr.employee'].search([('id', '=', self.employee_id.id)]).wecom_userid + self.sudo().env["wecom.apps"].sync_send_message_textcard(category='default', user_id=we_id, title="考勤确认", + description=self.employee_id.name + '请确认你的考勤:', + url=url, btntxt="详细信息") + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': '确认通知已发送', + 'sticky': False, + } + } + + def button_all_put(self): + detail_ids = self.env["yuthon.vacation.reports"].browse(self._context.get('active_ids', self._context.get('active_id'))) + unique_employee_ids = list({detail.employee_id.id for detail in detail_ids if detail.employee_id}) + for employee_id in unique_employee_ids: + menu_id = self.env['ir.ui.menu'].search([('name', '=', '考勤确认'), ('parent_id', '!=', False)]) + url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=hr.attendance.month.detail&view_type=list&menu_id={menu_id.id}' + we_id = self.env['hr.employee'].search([('id', '=', employee_id)]).wecom_userid + self.sudo().env["wecom.apps"].sync_send_message_textcard(category='attendance', user_id=we_id, title="考勤确认", + description=employee_id.name + '请确认你的考勤:', + url=url, btntxt="详细信息") + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'message': '确认通知已发送', + 'sticky': False, + } + } + @api.depends('medical_fee_ids.update_type', 'medical_fee_ids.lines', 'medical_fee_ids.is_void') def _compute_medical_fee(self): @@ -172,7 +242,6 @@ class YuthonVacationReports(models.Model): overtime_hours += line_total elif line.update_type == 'reduce': overtime_hours -= line_total - overtime_days = overtime_hours / 8 record.working_overtime = f"{overtime_hours:.2f}小时({overtime_days:.2f}天)" @@ -188,34 +257,6 @@ class YuthonVacationReports(models.Model): meal_total -= int(line.update_lines or 0) record.meal_fee = meal_total - def button_fixes_approval(self): - form_id = self.env.ref('yuthon_holiday.view_yuthon_fixes_approval_form').id - return { - "type": "ir.actions.act_window", - "name": "修正申请", - "res_model": "yuthon.fixes.approval", - "views": [[form_id, "form"]], - "context": { - 'default_users_id': self.employee_id.user_id.id, - 'default_vacation_id': self.id, - 'default_now_type': 'hours', - 'default_holiday_status': 'annual' - } - } - - def vacation_details(self): - domain =[('workflow_id.name', 'in', ['请假', '加班', '外出']), ('create_uid', '=', self.employee_id.user_id.id)] - action = { - 'name': '审批详情', - 'type': 'ir.actions.act_window', - 'res_model': 'soong.workflow.record', - 'view_mode': 'tree', - 'domain': domain, - 'context': {'group_by': ['workflow_id'], - 'tree_view_ref':'yuthon_holiday.details_tree_view', - }} - return action - def update_vacation(self): employees = self.env['hr.employee'].search([ ('is_salary', '=', True), diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml index ab5c957ef..949ea530f 100644 --- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml +++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml @@ -4,15 +4,39 @@ yuthon.vacation.reports.tree yuthon.vacation.reports - - + + + + + + + + + - - -