diff --git a/yuthon_duty_plan/__init__.py b/yuthon_duty_plan/__init__.py
index 9b4296142..0650744f6 100644
--- a/yuthon_duty_plan/__init__.py
+++ b/yuthon_duty_plan/__init__.py
@@ -1,2 +1 @@
from . import models
-from . import wizard
diff --git a/yuthon_duty_plan/__manifest__.py b/yuthon_duty_plan/__manifest__.py
index 3c9388857..d817fbf93 100644
--- a/yuthon_duty_plan/__manifest__.py
+++ b/yuthon_duty_plan/__manifest__.py
@@ -11,7 +11,7 @@
'sequence': 240,
'website': 'https://www.pengyuthon.com',
'depends': ['hr_attendance', 'resource', 'base', 'hr', 'mail',
- 'soong_workflow', 'yuthon_issue', 'planning', 'calendar'],
+ 'soong_workflow', 'yuthon_issue','calendar'],
'data': [
'security/ir.model.access.csv',
'data/arrangement_time_data.xml',
@@ -25,8 +25,6 @@
'views/yuthon_abnormal_setting_views.xml',
'views/yuthon_adjustments_approval_views.xml',
'views/yuthon_shift_approval_views.xml',
- 'wizard/yuthon_duty_arrangement_wizard_views.xml',
- 'wizard/yuthon_duty_summary_wizard_views.xml',
],
'installable': True,
'application': True,
diff --git a/yuthon_duty_plan/models/yuthon_duty_arrangement.py b/yuthon_duty_plan/models/yuthon_duty_arrangement.py
index 9f67b4bab..fd9ae50f7 100644
--- a/yuthon_duty_plan/models/yuthon_duty_arrangement.py
+++ b/yuthon_duty_plan/models/yuthon_duty_arrangement.py
@@ -9,8 +9,8 @@ class YuthonDutyArrangement(models.Model):
_order = 'start_time desc'
_rec_name = 'employee_id'
- employee_id = fields.Many2one('hr.employee', string='员工',
- domain=lambda self: [('department_id.name', '=', '仓储组')])
+ employee_id = fields.Many2one('hr.employee', string='员工')
+ duty_class_id = fields.Many2one('yuthon.duty.class.setting', string="班组名称")
start_time = fields.Date(string="开始日期")
end_time = fields.Date(string="结束日期")
remarks = fields.Text(string='备注')
@@ -101,3 +101,6 @@ class YuthonDutyArrangement(models.Model):
title="值班安排",
description='本月的值班表已确认,请查看',
url=str, btntxt="详细信息")
+
+ def button_all_duty(self):
+ pass
diff --git a/yuthon_duty_plan/models/yuthon_duty_plan.py b/yuthon_duty_plan/models/yuthon_duty_plan.py
index d6e1c970e..1f200fd28 100644
--- a/yuthon_duty_plan/models/yuthon_duty_plan.py
+++ b/yuthon_duty_plan/models/yuthon_duty_plan.py
@@ -12,30 +12,44 @@ class YuthonDutyPlan(models.Model):
end_index_time = fields.Date(string='失效时间')
is_enable = fields.Boolean(string="启用", default=True)
plan_line_ids = fields.One2many('duty.plan.line', 'duty_plan_id', string='关联计划明细')
+ notice = fields.Text(string='计划说明')
def auto_duty_plan(self):
- employee_ids = self.env['hr.employee'].search([('department_id.name', 'in', ['仓储组', '综合组', '保管组', '机安组',
- '1库', '2库', '3库', '联安粮库'])])
- self.plan_line_ids.unlink()
- sequence = 1
- for employee in employee_ids:
- self.env['duty.plan.line'].create({
- 'duty_plan_id': self.id,
- 'sequence': sequence,
- 'employee_id': employee.id
- })
- sequence += 1
+ today = datetime.today().date()
+ first_day_of_month = today.replace(day=1)
+ if today.month < 12:
+ last_day_of_month = (today.replace(month=today.month + 1, day=1) - timedelta(days=1))
+ else:
+ last_day_of_month = (today.replace(year=today.year + 1, month=1, day=1) - timedelta(days=1))
+ duty_lines = []
+ current_date = first_day_of_month
+ while current_date <= last_day_of_month:
+ for line in self.plan_line_ids:
+ for employee in line.employee_ids:
+ duty_lines.append({
+ 'employee_id': employee.id,
+ 'start_time': current_date,
+ 'end_time': current_date,
+ 'duty_class_id': line.duty_class_id.id,
+ })
+ current_date += timedelta(days=1)
+ if current_date > last_day_of_month:
+ break
+ self.env['yuthon.duty.arrangement'].create(duty_lines)
+ tree_id = self.env.ref("yuthon_duty_plan.view_yuthon_duty_arrangement_tree").id
+ return {
+ "type": "ir.actions.act_window",
+ "name": "值班安排",
+ "res_model": "yuthon.duty.arrangement",
+ "views": [[tree_id, "tree"]],
+ }
class DutyPlanLine(models.Model):
_name = 'duty.plan.line'
_description = '值班计划明细行'
- _order = 'sequence asc'
+ sequence = fields.Char(string='序号', store=True)
duty_plan_id = fields.Many2one('yuthon.duty.plan', string='关联计划名称')
- sequence = fields.Integer(string='序号')
- employee_id = fields.Many2one('hr.employee', string='员工',
- domain=lambda self: [('department_id.name', 'in', ['仓储组', '综合组',
- '保管组', '机安组',
- '1库', '2库', '3库',
- '联安粮库'])])
+ employee_ids = fields.Many2many('hr.employee', string='值班人员')
+ duty_class_id = fields.Many2one('yuthon.duty.class.setting', string="班组名称")
diff --git a/yuthon_duty_plan/models/yuthon_duty_setting.py b/yuthon_duty_plan/models/yuthon_duty_setting.py
index 22664210d..e892891d9 100644
--- a/yuthon_duty_plan/models/yuthon_duty_setting.py
+++ b/yuthon_duty_plan/models/yuthon_duty_setting.py
@@ -6,3 +6,11 @@ class YuthonDutySetting(models.Model):
_description = '值班说明配置'
reason_application = fields.Html(string="说明")
+
+
+class YuthonDutyClassSetting(models.Model):
+ _name = 'yuthon.duty.class.setting'
+ _description = '值班班组配置'
+ _rec_name = 'name'
+
+ name = fields.Char(string="班组名称")
diff --git a/yuthon_duty_plan/security/ir.model.access.csv b/yuthon_duty_plan/security/ir.model.access.csv
index c698edd4b..612bdadaa 100644
--- a/yuthon_duty_plan/security/ir.model.access.csv
+++ b/yuthon_duty_plan/security/ir.model.access.csv
@@ -1,14 +1,10 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_yuthon_duty_arrangement,yuthon.duty.arrangement,model_yuthon_duty_arrangement,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_plan,yuthon.duty.plan,model_yuthon_duty_plan,base.group_user,1,1,1,1
access_duty_plan_line,duty.plan.line,model_duty_plan_line,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_class_setting,yuthon.duty.class.setting,model_yuthon_duty_class_setting,base.group_user,1,1,1,1
access_yuthon_duty_summary,yuthon.duty.summary,model_yuthon_duty_summary,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
-
-
-access_duty_approval_line,duty.approval.line,model_duty_approval_line,base.group_user,1,1,1,1
access_yuthon_adjustments_approval,yuthon.adjustments.approval,model_yuthon_adjustments_approval,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
diff --git a/yuthon_duty_plan/views/yuthon_duty_arrangement_views.xml b/yuthon_duty_plan/views/yuthon_duty_arrangement_views.xml
index 4ada78d4c..e84a9966e 100644
--- a/yuthon_duty_plan/views/yuthon_duty_arrangement_views.xml
+++ b/yuthon_duty_plan/views/yuthon_duty_arrangement_views.xml
@@ -5,7 +5,11 @@
yuthon.duty.arrangement
+
+
@@ -13,8 +17,8 @@
-
-
+
+
@@ -75,10 +79,25 @@
+
+ yuthon.duty.arrangement.calendar
+ yuthon.duty.arrangement
+
+
+
+
+
+
值班安排
yuthon.duty.arrangement
- tree,form
+ tree,form,calendar,search
{'search_default_current_month': 1}
diff --git a/yuthon_duty_plan/views/yuthon_duty_plan_views.xml b/yuthon_duty_plan/views/yuthon_duty_plan_views.xml
index 74b709bc1..8f127468a 100644
--- a/yuthon_duty_plan/views/yuthon_duty_plan_views.xml
+++ b/yuthon_duty_plan/views/yuthon_duty_plan_views.xml
@@ -18,7 +18,7 @@
diff --git a/yuthon_duty_plan/views/yuthon_duty_setting_views.xml b/yuthon_duty_plan/views/yuthon_duty_setting_views.xml
index 41eda53ae..52db58782 100644
--- a/yuthon_duty_plan/views/yuthon_duty_setting_views.xml
+++ b/yuthon_duty_plan/views/yuthon_duty_setting_views.xml
@@ -27,4 +27,33 @@
yuthon.duty.setting
tree,form
+
+
+
+ yuthon.duty.class.setting.tree
+ yuthon.duty.class.setting
+
+
+
+
+
+
+
+ yuthon.duty.class.setting.form
+ yuthon.duty.class.setting
+
+
+
+
+
+ 值班说明
+ yuthon.duty.class.setting
+ tree,form
+
diff --git a/yuthon_duty_plan/wizard/__init__.py b/yuthon_duty_plan/wizard/__init__.py
deleted file mode 100644
index 993e31f28..000000000
--- a/yuthon_duty_plan/wizard/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from . import yuthon_duty_arrangement_wizard
-from . import yuthon_duty_summary_wizard
diff --git a/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard.py b/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard.py
deleted file mode 100644
index 28f7e973e..000000000
--- a/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard.py
+++ /dev/null
@@ -1,57 +0,0 @@
-from odoo import api, fields, models, tools
-from odoo.exceptions import ValidationError, UserError
-from datetime import date, timedelta
-import random
-
-
-class YuthonDutyArrangementWizard(models.TransientModel):
- _name = 'yuthon.duty.arrangement.wizard'
- _description = '自动安排值班弹窗'
-
- number_personnel = fields.Integer(string='人数', help="多少人一循环")
- remake = fields.Text(string='备注', default='一次只能排当月的,注意会清空当月数据随机生成。')
-
- def confirm(self):
- num_people = self.number_personnel
- duty_id = self.env['yuthon.duty.plan'].search([('is_enable', '=', True)])
- existing_lines = self.env['duty.plan.line'].search([('duty_plan_id', '=', duty_id.id)])
- available_people = existing_lines.mapped('employee_id.id')
- if len(available_people) < num_people:
- raise UserError("现有值班计划的员工数量不足以满足需求!")
- selected_people = random.sample(available_people, num_people)
- today = date.today()
- first_day_of_month = today.replace(day=1)
- last_day_of_month = (today.replace(day=1) + timedelta(days=32)).replace(day=1) - timedelta(days=1)
- self.env['yuthon.duty.arrangement'].search([
- ('start_time', '>=', first_day_of_month),
- ('start_time', '<=', last_day_of_month),
- ]).unlink()
- today = date.today()
- next_month = (today.replace(day=1) + timedelta(days=32)).replace(day=1)
- current_date = today
- while current_date < next_month:
- for employee in selected_people:
- self.env['yuthon.duty.arrangement'].create({
- 'employee_id': employee,
- 'start_time': current_date,
- 'end_time': current_date + timedelta(days=1), # 值班一天
- })
- current_date += timedelta(days=1)
-
- tree_id = self.env.ref("yuthon_duty_plan.view_yuthon_duty_arrangement_tree").id
- return {
- "type": "ir.actions.act_window",
- "name": "值班安排",
- "res_model": "yuthon.duty.arrangement",
- "views": [[tree_id, "tree"]],
- }
-
- @api.model
- def action_hr_employee(self):
- return {
- 'type': 'ir.actions.act_window',
- 'name': '自动安排值班',
- 'res_model': self._name,
- 'view_mode': 'form',
- 'target': 'new',
- }
\ No newline at end of file
diff --git a/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard_views.xml b/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard_views.xml
deleted file mode 100644
index 05b2ee850..000000000
--- a/yuthon_duty_plan/wizard/yuthon_duty_arrangement_wizard_views.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- yuthon.duty.arrangement.wizard.form
- yuthon.duty.arrangement.wizard
-
-
-
-
-
- 自动安排
-
- code
- action = model.action_hr_employee()
-
-
-
\ No newline at end of file
diff --git a/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard.py b/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard.py
deleted file mode 100644
index f7e37de40..000000000
--- a/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from dateutil.relativedelta import relativedelta
-
-from odoo import api, fields, models, tools, _
-from datetime import date, timedelta, datetime
-
-
-class YuthonDutySummaryWizard(models.TransientModel):
- _name = 'yuthon.duty.summary.wizard'
- _description = '值班汇总计算'
-
- select_the_month = fields.Selection([('one', '一月'), ('two', '二月'), ('three', '三月'),
- ('four', '四月'), ('five', '五月'), ('six', '六月'),
- ('seven', '七月'), ('eight', '八月'), ('nine', '九月'), ('ten', '十月'),
- ('eleven', '十一月'), ('twelve', '十二月')], string='选择月份', default=lambda self: self._get_current_month())
-
- @api.model
- def _get_current_month(self):
- current_month = datetime.now().month
- month_mapping = {
- 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five',
- 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten',
- 11: 'eleven', 12: 'twelve'
- }
- return month_mapping.get(current_month, 'one')
-
- @api.model
- def action_duty_summary_wizard(self):
- return {
- 'type': 'ir.actions.act_window',
- 'name': '值班总汇计算',
- 'res_model': self._name,
- 'view_mode': 'form',
- 'target': 'new',
- }
-
- def confirm(self):
- pass
\ No newline at end of file
diff --git a/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard_views.xml b/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard_views.xml
deleted file mode 100644
index c3d65ed1f..000000000
--- a/yuthon_duty_plan/wizard/yuthon_duty_summary_wizard_views.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- yuthon.duty.summary.wizard.form
- yuthon.duty.summary.wizard
-
-
-
-
-
- 值班汇总计算
-
- code
- action = model.action_duty_summary_wizard()
-
-
-
diff --git a/yuthon_hr_attendance/controllers/attendance_banner_route.py b/yuthon_hr_attendance/controllers/attendance_banner_route.py
index 61a8e6a89..8266a2ee7 100644
--- a/yuthon_hr_attendance/controllers/attendance_banner_route.py
+++ b/yuthon_hr_attendance/controllers/attendance_banner_route.py
@@ -8,11 +8,8 @@ class AttendanceBannerRoute(Controller):
@route('/attendance/banner/route', type='json', auth='user')
def employee_banner_route(self):
current_date = datetime.today()
- # 获取当前月份的开始和结束时间
month_start = current_date.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
- month_end = (current_date.replace(day=1, hour=0, minute=0, second=0, microsecond=0) + relativedelta(
- months=1)) - timedelta(seconds=1)
- # 查询当前用户本月的考勤记录
+ month_end = (current_date.replace(day=1, hour=0, minute=0, second=0, microsecond=0) + relativedelta(months=1)) - timedelta(seconds=1)
domain = [
('employee_id.user_id', '=', request.env.user.id),
('check_in', '>=', month_start),
diff --git a/yuthon_hr_attendance/models/go_approval.py b/yuthon_hr_attendance/models/go_approval.py
index 1247eea24..50e723f12 100644
--- a/yuthon_hr_attendance/models/go_approval.py
+++ b/yuthon_hr_attendance/models/go_approval.py
@@ -77,7 +77,7 @@ class GoApprovalsLine(models.Model):
users_id = fields.Many2one('res.users', string="外出人")
applicants_unit = fields.Selection([('hour', '小时'), ('day', '天')], string="申请单位")
documents_ids = fields.Many2many('ir.attachment', string="附件")
- date_start = fields.Datetime(string="开始时间", date_start = fields.Datetime(string="开始时间", default=lambda self: datetime.now().replace(hour=8, minute=30, second=0, microsecond=0)))
+ date_start = fields.Datetime(string="开始时间", date_start=fields.Datetime(string="开始时间", default=lambda self: datetime.now().replace(hour=8, minute=30, second=0, microsecond=0)))
date_end = fields.Datetime(string="结束时间")
@api.onchange('date_start', 'date_end')
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index bcc9370d0..1ead8b565 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -143,11 +143,11 @@ class HrAttendance(models.Model):
}
def button_duty_approval(self):
- form_id = self.env.ref('yuthon_hr_attendance.duty_approval_form').id
+ form_id = self.env.ref('yuthon_hr_attendance.go_approval_form').id
return {
"type": "ir.actions.act_window",
"name": "外出申请",
- "res_model": "duty.approval",
+ "res_model": "go.approval",
"views": [[form_id, "form"]],
"context": {
'default_users_id': self.employee_id.user_id.id,
diff --git a/yuthon_hr_attendance/security/ir.model.access.csv b/yuthon_hr_attendance/security/ir.model.access.csv
index ea9af534b..74f5a98f5 100644
--- a/yuthon_hr_attendance/security/ir.model.access.csv
+++ b/yuthon_hr_attendance/security/ir.model.access.csv
@@ -18,4 +18,5 @@ access_yuthon_yuthon_overall_planning,yuthon.overall.planning,model_yuthon_overa
access_yuthon_engineering_overall_planning,engineering.overall.planning,model_yuthon_engineering_overall_planning,base.group_user,1,1,1,1
access_yuthon_run_planning,yuthon.run.planning,model_yuthon_run_planning,base.group_user,1,1,1,1
access_yuthon_engineering_run_line,engineering.run.line,model_yuthon_engineering_run_line,base.group_user,1,1,1,1
-access_duty_approval,duty.approval,model_duty_approval,base.group_user,1,1,1,1
\ No newline at end of file
+access_duty_approval,duty.approval,model_duty_approval,base.group_user,1,1,1,1
+access_duty_approval_line,duty.approval.line,model_duty_approval_line,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_hr_attendance/views/all_attendance_menu.xml b/yuthon_hr_attendance/views/all_attendance_menu.xml
index 4ebdd5c8c..148314984 100644
--- a/yuthon_hr_attendance/views/all_attendance_menu.xml
+++ b/yuthon_hr_attendance/views/all_attendance_menu.xml
@@ -1,9 +1,5 @@
-
-
-