添加功能
This commit is contained in:
@@ -31,7 +31,8 @@ class HrAttendance(models.Model):
|
||||
('four', '星期四'), ('five', '星期五'), ('six', '星期六'),
|
||||
('seven', '星期日')], string='星期', compute='_compute_week', store=True)
|
||||
abnormal = fields.Integer(string="异常计算")
|
||||
shift = fields.Char(string="班次")
|
||||
shift_id = fields.Many2one('planning.slot', string="班次", compute='compute_shift_id', store=True)
|
||||
shift_name = fields.Char(string="班次", related="shift_id.template_id.planning_name")
|
||||
noon_duty = fields.Datetime(string="中值")
|
||||
night_duty = fields.Datetime(string="晚值")
|
||||
is_approval = fields.Boolean(string="是否审批修正", default=False)
|
||||
@@ -466,7 +467,7 @@ class HrAttendance(models.Model):
|
||||
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=employee_id.wecom_userid, message=data)
|
||||
|
||||
def card_out_comment(self, employee_id,planning_name):
|
||||
data = f"您的班次是{planning_name},您该下班时间,记得打卡"
|
||||
data = f"您的班次是{planning_name},您该下班了,记得打卡"
|
||||
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=employee_id.wecom_userid, message=data)
|
||||
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id='18562027762', message=data)
|
||||
|
||||
@@ -475,6 +476,23 @@ class HrAttendance(models.Model):
|
||||
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=employee_id.wecom_userid, message=data)
|
||||
self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id='18562027762', message=data)
|
||||
|
||||
@api.depends('employee_id')
|
||||
def compute_shift_id(self):
|
||||
target_departments = ['工程部', '保安部', '联安粮库']
|
||||
departments = self.env['hr.department'].search([('name', 'in', target_departments)])
|
||||
all_child_departments = self.env['hr.department'].search([('id', 'child_of', departments.ids)])
|
||||
employees = self.env['hr.employee'].search([('department_id', 'in', all_child_departments.ids)])
|
||||
|
||||
for employee in employees:
|
||||
planning_slots = self.env['planning.slot'].search([('resource_id', '=', employee.resource_id.id)])
|
||||
for slot in planning_slots:
|
||||
start_date = slot.start_datetime.date()
|
||||
attendance = self.env['hr.attendance'].search([
|
||||
('employee_id', '=', employee.id),
|
||||
('current_data', '=', start_date)
|
||||
])
|
||||
if attendance:
|
||||
attendance.write({'shift_id': slot.shift_id.id})
|
||||
|
||||
class card_remind_form(models.Model):
|
||||
_name = 'card.remind.form'
|
||||
|
||||
@@ -49,9 +49,9 @@ class YuthonShiftPlanning(models.Model):
|
||||
role_template_c = self.env['planning.slot.template'].search([('planning_name', '=', '夜班'), ('role_id', '=', role_a.id)])
|
||||
role = [role_template_a, role_template_b, role_template_c]
|
||||
planning_groups = {
|
||||
'planning_a_ids': range(len(role)), # 默认顺序: 早 -> 中 -> 夜
|
||||
'planning_c_ids': [1, 2, 0], # 中 -> 夜 -> 早
|
||||
'planning_b_ids': [2, 0, 1], # 夜 -> 早 -> 中
|
||||
'planning_a_ids': [0, 2, 1], # 早 -> 夜 -> 中
|
||||
'planning_b_ids': [2, 1, 0], # 夜 -> 中 -> 早
|
||||
'planning_c_ids': [1, 0, 2], # 中 -> 早 -> 夜
|
||||
}
|
||||
|
||||
weekday_mapping = {
|
||||
@@ -154,6 +154,21 @@ class YuthonShiftPlanning(models.Model):
|
||||
def shift_next_planing(self):
|
||||
self.confirm(next_date=True)
|
||||
|
||||
def exchange_button(self):
|
||||
for record in self:
|
||||
white_lines = record.planning_ever_white_ids
|
||||
noon_lines = record.planning_ever_noon_ids
|
||||
white_data = [{'employee_id': line.employee_id.id, 'sequence': line.sequence,
|
||||
'regular_holidays': line.regular_holidays} for line in white_lines]
|
||||
noon_data = [{'employee_id': line.employee_id.id, 'sequence': line.sequence,
|
||||
'regular_holidays': line.regular_holidays} for line in noon_lines]
|
||||
white_lines.unlink()
|
||||
noon_lines.unlink()
|
||||
for data in noon_data:
|
||||
record.planning_ever_white_ids = [(0, 0, data)]
|
||||
for data in white_data:
|
||||
record.planning_ever_noon_ids = [(0, 0, data)]
|
||||
|
||||
class YuthonShiftPlanningALine(models.Model):
|
||||
_name = 'yuthon.shift.planning.a.line'
|
||||
_description = '排班安排A组'
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<field name="work_time_type" optional="hidden"/>
|
||||
<field name="check_in" optional="show" widget="time"/>
|
||||
<field name="check_out" optional="show" widget="time"/>
|
||||
<field name="shift" optional="show"/>
|
||||
<field name="shift_name" optional="show"/>
|
||||
<field name="is_approval" column_invisible="1"/>
|
||||
<button name="button_leave" type="object" string="请假" class="oe_highlight"
|
||||
invisible="not is_abnormal"/>
|
||||
@@ -81,7 +81,7 @@
|
||||
<field name="noon_duty" optional="show" widget="time"/>
|
||||
<field name="night_duty" optional="show" widget="time"/>
|
||||
<field name="check_out" optional="show" widget="time"/>
|
||||
<field name="shift" optional="show"/>
|
||||
<field name="shift_name" optional="show"/>
|
||||
<field name="is_approval" column_invisible="1"/>
|
||||
<button name="button_leave" type="object" string="请假" class="oe_highlight"
|
||||
invisible="not is_abnormal"/>
|
||||
@@ -113,7 +113,7 @@
|
||||
<field name="check_in" optional="show" widget="time"/>
|
||||
<field name="noon_duty" optional="show" widget="time"/>
|
||||
<field name="check_out" optional="show" widget="time"/>
|
||||
<field name="shift" optional="show"/>
|
||||
<field name="shift_name" optional="show"/>
|
||||
<field name="is_approval" column_invisible="1"/>
|
||||
<button name="button_leave" type="object" string="请假" class="oe_highlight"
|
||||
invisible="not is_abnormal"/>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<button name="exchange_button" type="object" string="交换" class="oe_highlight" />
|
||||
<group string="常白班">
|
||||
<field name="planning_ever_white_ids" string=" ">
|
||||
<tree editable="bottom">
|
||||
|
||||
Reference in New Issue
Block a user