diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py
index 22ef53c19..9e13897a3 100644
--- a/yuthon_hr_attendance/__manifest__.py
+++ b/yuthon_hr_attendance/__manifest__.py
@@ -27,6 +27,7 @@
'views/yuthon_duty_arrangement_views.xml',
'views/yuthon_duty_summary_views.xml',
'views/yuthon_duty_setting_views.xml',
+ 'views/yuthon_abnormal_approval_views.xml',
# 'views/attendance_iot_datas.xml',
# 'views/attendance_iot_manager_views.xml',
# 'views/attendance_iot_views.xml',
diff --git a/yuthon_hr_attendance/models/__init__.py b/yuthon_hr_attendance/models/__init__.py
index 45b787a5c..7d3fb78cc 100644
--- a/yuthon_hr_attendance/models/__init__.py
+++ b/yuthon_hr_attendance/models/__init__.py
@@ -26,5 +26,6 @@ from . import yuthon_duty_summary
from . import yuthon_adjustments_approval
from . import yuthon_duty_arrangement
from . import yuthon_duty_setting
+from . import yuthon_abnormal_approval
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index 93588fe65..ac73e3fba 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -41,3 +41,26 @@ class HrAttendance(models.Model):
for record in self:
record.is_abnormal = record.is_no_card or record.is_early_card or record.is_late_card
+ def button_leave(self):
+ form_id = self.env.ref('yuthon_holiday.view_hr_leave_batch_form').id
+ return {
+ "type": "ir.actions.act_window",
+ "name": "请假申请",
+ "res_model": "hr.leave.batch",
+ "views": [[form_id, "form"]],
+ "context": {
+ 'default_leave_id': self.employee_id.user_id.id,
+ }
+ }
+
+ def button_compensatory_leave(self):
+ form_id = self.env.ref('yuthon_hr_attendance.view_yuthon_adjustments_approval_form').id
+ return {
+ "type": "ir.actions.act_window",
+ "name": "调休申请",
+ "res_model": "yuthon.adjustments.approval",
+ "views": [[form_id, "form"]],
+ "context": {
+ 'default_users_id': self.employee_id.user_id.id,
+ }
+ }
\ No newline at end of file
diff --git a/yuthon_hr_attendance/models/yuthon_abnormal_approval.py b/yuthon_hr_attendance/models/yuthon_abnormal_approval.py
new file mode 100644
index 000000000..26e21f588
--- /dev/null
+++ b/yuthon_hr_attendance/models/yuthon_abnormal_approval.py
@@ -0,0 +1,38 @@
+from odoo import api, fields, models, tools, _
+from datetime import datetime, time, timedelta
+from odoo.exceptions import UserError
+
+
+class YuthonAbnormalApproval(models.Model):
+ _name = 'yuthon.abnormal.approval'
+ _inherit = ['soong.workflow.mixin']
+ _description = '值班异常审批'
+ _rec_name = 'name'
+
+ yuthon_company = fields.Selection(related='users_id.employee_id.yuthon_company', string="公司")
+ 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="部门")
+ is_issues = fields.Boolean(string='是否上会')
+ related_issues_id = fields.Many2one('issue.library', string="关联议题")
+ reason_application = fields.Html(string="申请事由")
+ documents_ids = fields.Many2many('ir.attachment', string="附件")
+ active = fields.Boolean('Active', default=True, tracking=True)
+
+ @api.onchange('is_issues')
+ def _onchange_is_issues(self):
+ if self.is_issues:
+ issue_id = self.env['issue.library'].create({'name': self.name})
+ self.related_issues_id = issue_id.id
+ workflow_record_id = self.env["soong.workflow.record"].search(
+ [("res_model", "=", self._name), ("res_id", "=", self.id)])
+ self.env['issue.library.approval.line'].create({
+ 'issue_library_id': issue_id.id,
+ 'workflow_record_id': workflow_record_id.id,
+ 'approval_type': workflow_record_id.workflow_id.id,
+ 'code': self.code,
+ 'approval_date': fields.Datetime.now(),
+ })
+ elif self.related_issues_id:
+ raise UserError("已经创建了相关的上会记录,不能取消勾选")
\ No newline at end of file
diff --git a/yuthon_hr_attendance/models/yuthon_duty_arrangement.py b/yuthon_hr_attendance/models/yuthon_duty_arrangement.py
index 503310edc..5a4f74212 100644
--- a/yuthon_hr_attendance/models/yuthon_duty_arrangement.py
+++ b/yuthon_hr_attendance/models/yuthon_duty_arrangement.py
@@ -51,5 +51,18 @@ class YuthonDutyArrangement(models.Model):
}
}
- def duty_arrangement_time(self):
- pass
\ No newline at end of file
+ def button_abnormal(self):
+ for record in self:
+ if record.is_abnormal:
+ form_id = self.env.ref("yuthon_hr_attendance.view_yuthon_abnormal_approval_form").id
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': '异常申请',
+ 'res_model': 'yuthon.abnormal.approval',
+ "views": [[form_id, "form"]],
+ "context": {
+ 'default_users_id':self.employee_id.user_id.id,
+ }
+ }
+ else:
+ raise UserError('当前日期无异常')
diff --git a/yuthon_hr_attendance/security/ir.model.access.csv b/yuthon_hr_attendance/security/ir.model.access.csv
index 9f5273462..dd1eb8c01 100644
--- a/yuthon_hr_attendance/security/ir.model.access.csv
+++ b/yuthon_hr_attendance/security/ir.model.access.csv
@@ -15,4 +15,5 @@ access_yuthon_adjustments_approval,yuthon.adjustments.approval,model_yuthon_adju
access_yuthon_duty_arrangement,yuthon.duty.arrangement,model_yuthon_duty_arrangement,base.group_user,1,1,1,1
access_yuthon_duty_setting,yuthon.duty.setting,model_yuthon_duty_setting,base.group_user,1,1,1,1
access_yuthon_duty_arrangement_wizard,yuthon.duty.arrangement.wizard,model_yuthon_duty_arrangement_wizard,base.group_user,1,1,1,1
-access_yuthon_duty_summary_wizard,yuthon.duty.summary.wizard,model_yuthon_duty_summary_wizard,base.group_user,1,1,1,1
\ No newline at end of file
+access_yuthon_duty_summary_wizard,yuthon.duty.summary.wizard,model_yuthon_duty_summary_wizard,base.group_user,1,1,1,1
+access_yuthon_abnormal_approval,yuthon.abnormal.approval,model_yuthon_abnormal_approval,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_hr_attendance/views/hr_attendance_views.xml b/yuthon_hr_attendance/views/hr_attendance_views.xml
index 5fae7bf2b..80f076674 100644
--- a/yuthon_hr_attendance/views/hr_attendance_views.xml
+++ b/yuthon_hr_attendance/views/hr_attendance_views.xml
@@ -19,6 +19,8 @@
+
+
diff --git a/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml b/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml
new file mode 100644
index 000000000..a3e02ad46
--- /dev/null
+++ b/yuthon_hr_attendance/views/yuthon_abnormal_approval_views.xml
@@ -0,0 +1,49 @@
+
+
+
+ yuthon.abnormal.approval.tree
+ yuthon.abnormal.approval
+
+
+
+
+
+
+
+
+
+
+ yuthon.abnormal.approval.form
+ yuthon.abnormal.approval
+
+
+
+
+
+ 异常审批
+ yuthon.abnormal.approval
+ tree,form
+
+
\ No newline at end of file
diff --git a/yuthon_hr_attendance/views/yuthon_duty_arrangement_views.xml b/yuthon_hr_attendance/views/yuthon_duty_arrangement_views.xml
index 95e27a24b..97fb68d6b 100644
--- a/yuthon_hr_attendance/views/yuthon_duty_arrangement_views.xml
+++ b/yuthon_hr_attendance/views/yuthon_duty_arrangement_views.xml
@@ -14,6 +14,7 @@
+
diff --git a/yuthon_hr_employee/static/others/user_template.xlsx b/yuthon_hr_employee/static/others/user_template.xlsx
index 31abb9116..2c4f3b209 100644
Binary files a/yuthon_hr_employee/static/others/user_template.xlsx and b/yuthon_hr_employee/static/others/user_template.xlsx differ