From 9f0d63876a2671486d67b008fd45d68e955430ac Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Thu, 12 Dec 2024 14:24:04 +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 --- .../models/inherit_planning_role.py | 11 +++++++++ .../models/yuthon_shift_approval.py | 23 +++++++++++++++---- yuthon_hr_attendance/views/duty_approval.xml | 11 ++++----- yuthon_hr_attendance/views/go_approval.xml | 6 ++--- .../views/overtime_approval.xml | 8 +++---- .../views/yuthon_duty_plan_views.xml | 6 ++--- .../views/yuthon_run_planning_views.xml | 12 +++++----- .../views/yuthon_shift_approval_views.xml | 21 +++++++++++------ .../views/yuthon_shift_planning_views.xml | 6 ++--- yuthon_work_brand/views/attendance_menu.xml | 6 ++--- 10 files changed, 70 insertions(+), 40 deletions(-) diff --git a/yuthon_hr_attendance/models/inherit_planning_role.py b/yuthon_hr_attendance/models/inherit_planning_role.py index efa164551..9773d2773 100644 --- a/yuthon_hr_attendance/models/inherit_planning_role.py +++ b/yuthon_hr_attendance/models/inherit_planning_role.py @@ -1,3 +1,5 @@ +from datetime import timedelta + from odoo import api, fields, models, tools from odoo.exceptions import ValidationError @@ -34,3 +36,12 @@ class InheritPlanningSlot(models.Model): _inherit = 'planning.slot' department_id = fields.Many2one('hr.department', string="部门") + + @api.depends('start_datetime', 'end_datetime', 'template_id') + def _compute_display_name(self): + for slot in self: + start_str = (slot.start_datetime + timedelta(hours=8)).strftime("%Y/%m/%d %H:%M") if slot.start_datetime else "" + end_str = (slot.end_datetime + timedelta(hours=8)).strftime("%Y/%m/%d %H:%M") if slot.end_datetime else "" + planning_name = slot.template_id.planning_name if slot.template_id and slot.template_id.planning_name else "" + slot.display_name = f"{start_str}-{end_str}-{planning_name}" + diff --git a/yuthon_hr_attendance/models/yuthon_shift_approval.py b/yuthon_hr_attendance/models/yuthon_shift_approval.py index c8eb5d435..171d75b79 100644 --- a/yuthon_hr_attendance/models/yuthon_shift_approval.py +++ b/yuthon_hr_attendance/models/yuthon_shift_approval.py @@ -5,14 +5,18 @@ from odoo.exceptions import UserError class YuthonShiftApproval(models.Model): _name = 'yuthon.shift.approval' - _inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin'] + # _inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin'] _description = '值班换班审批' yuthon_company = fields.Selection(related='users_id.employee_id.yuthon_company', string="公司") + users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id) name = fields.Char(string="标题") code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('adjustments_approval')) - users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id) - department_id = fields.Many2one(related='users_id.employee_id.department_id', string="部门") + resource_id = fields.Many2one('resource.resource', string="申请人", default=lambda self: self.env.user.employee_id.resource_id.id) + transferees_id = fields.Many2one('resource.resource', string="调班对象") + shift_id = fields.Many2one('planning.slot', string="班次") + return_id = fields.Many2one('planning.slot', string="班次") + department_id = fields.Many2one(string="部门", related='users_id.department_id') is_issues = fields.Boolean(string='是否上会') related_issues_id = fields.Many2one('issue.library', string="关联议题") reason_application = fields.Html(string="申请事由") @@ -34,4 +38,15 @@ class YuthonShiftApproval(models.Model): 'approval_date': fields.Datetime.now(), }) elif self.related_issues_id: - raise UserError("已经创建了相关的上会记录,不能取消勾选") \ No newline at end of file + raise UserError("已经创建了相关的上会记录,不能取消勾选") + + def button_shift_approval(self): + shift_id = self.shift_id + return_id = self.return_id + original_shift_template_id = shift_id.template_id.id + shift_id.write({ + 'template_id': return_id.template_id.id, + }) + return_id.write({ + 'template_id':original_shift_template_id, + }) diff --git a/yuthon_hr_attendance/views/duty_approval.xml b/yuthon_hr_attendance/views/duty_approval.xml index 4eca2ffd0..8b0d31d21 100644 --- a/yuthon_hr_attendance/views/duty_approval.xml +++ b/yuthon_hr_attendance/views/duty_approval.xml @@ -1,13 +1,12 @@ - duty.approval.tree duty.approval - - + + @@ -27,14 +26,14 @@ - + - + - + diff --git a/yuthon_hr_attendance/views/go_approval.xml b/yuthon_hr_attendance/views/go_approval.xml index e0c509ab4..a2966df34 100644 --- a/yuthon_hr_attendance/views/go_approval.xml +++ b/yuthon_hr_attendance/views/go_approval.xml @@ -7,8 +7,6 @@ - - @@ -29,7 +27,7 @@ - + @@ -38,7 +36,7 @@ - + diff --git a/yuthon_hr_attendance/views/overtime_approval.xml b/yuthon_hr_attendance/views/overtime_approval.xml index d5096ac0c..4ae0479a5 100644 --- a/yuthon_hr_attendance/views/overtime_approval.xml +++ b/yuthon_hr_attendance/views/overtime_approval.xml @@ -7,8 +7,8 @@ - - + + @@ -30,7 +30,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/yuthon_hr_attendance/views/yuthon_duty_plan_views.xml b/yuthon_hr_attendance/views/yuthon_duty_plan_views.xml index 576f4a585..3c137511f 100644 --- a/yuthon_hr_attendance/views/yuthon_duty_plan_views.xml +++ b/yuthon_hr_attendance/views/yuthon_duty_plan_views.xml @@ -4,7 +4,7 @@ yuthon.duty.plan.tree yuthon.duty.plan - + @@ -16,7 +16,7 @@ yuthon.duty.plan.form yuthon.duty.plan -
+
@@ -57,7 +57,7 @@ - 排班安排 + 排版规则 yuthon.duty.plan tree,form diff --git a/yuthon_hr_attendance/views/yuthon_run_planning_views.xml b/yuthon_hr_attendance/views/yuthon_run_planning_views.xml index beec192a4..231591af0 100644 --- a/yuthon_hr_attendance/views/yuthon_run_planning_views.xml +++ b/yuthon_hr_attendance/views/yuthon_run_planning_views.xml @@ -4,7 +4,7 @@ yuthon.run.planning.tree yuthon.run.planning - + @@ -15,7 +15,7 @@ yuthon.run.planning.form yuthon.run.planning - +
- - - + + + + + + + - - + + diff --git a/yuthon_hr_attendance/views/yuthon_shift_planning_views.xml b/yuthon_hr_attendance/views/yuthon_shift_planning_views.xml index 38e25b856..e3ffaf61d 100644 --- a/yuthon_hr_attendance/views/yuthon_shift_planning_views.xml +++ b/yuthon_hr_attendance/views/yuthon_shift_planning_views.xml @@ -4,7 +4,7 @@ yuthon.shift.planning.tree yuthon.shift.planning - + @@ -15,7 +15,7 @@ yuthon.shift.planning.form yuthon.shift.planning - +