!9622 添加功能

Merge pull request !9622 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2026-03-12 02:43:58 +00:00
committed by Gitee
2 changed files with 17 additions and 67 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ class SoongWorkflowNode(models.Model):
for record in self:
now_btn = record.button_ids.filtered(lambda r: r.name in ["转交"])
for btn in now_btn:
other_btn = record.button_ids.filtered(lambda r: r.name not in ["转交", "收回", "加签", "加签确认"])
other_btn = record.button_ids.filtered(lambda r: r.name not in ["转交", "收回", "加签", "加签确认", '确认', '归档'])
other_btn.write({
"btn_hide": btn.btn_hide,
"review_type": btn.review_type,
+16 -66
View File
@@ -45,7 +45,13 @@ class YuthonCatering(models.Model):
})
def task_catering(self):
today = fields.Date.today()
employee_ids = self.env['yuthon.catering.conf'].search([])[0].employee_ids
future_menu_records = self.env['yuthon.menu.setting'].search([
('menu_date', '>', today)
])
if not future_menu_records:
return
for emp in employee_ids:
url = f"https://phone.thtzjt.com/phone/Restaurant/{emp.user_id.id}"
self.sudo().env["wecom.apps"].sync_send_message_textcard(
@@ -164,67 +170,6 @@ class YuthonCatering(models.Model):
if create_vals:
self.create(create_vals)
# 定义私有方法,用于判断给定日期是否为工作日
def _process_shift_days(self, current_data):
"""
判断是否是工作日 调休日 双休
"""
# 获取当前年份
current_year = (fields.Date.today() + timedelta(hours=8)).year
# 设置查询开始时间(当年1月1日)
query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
# 设置查询结束时间(当年12月31日)
query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
# 查询"行政考勤工作日"日历的假期设置
calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
("calendar_id.name", "=", "行政考勤工作日"),
("date_from", ">=", query_start),
("date_from", "<=", query_end)
])
# 初始化假期列表
holidays_list = []
# 初始化调休列表
shift_days_list = []
# 提取节假日和调休日
for leave in calendar_leaves:
# 如果有假期设置,添加到假期列表
if leave.holidays:
holidays_list.extend(leave.holidays.split(','))
# 如果有调休日设置,添加到假期列表
if leave.alternate_rest_day:
holidays_list.extend(leave.alternate_rest_day.split(','))
# 如果有换班日设置,添加到调休列表
if leave.shift_replacement_day:
shift_days_list.extend(leave.shift_replacement_day.split(','))
# 移除日期字符串中的前导零
holidays_list = [self.remove_leading_zero(date) for date in holidays_list]
# 移除日期字符串中的前导零
shift_days_list = [self.remove_leading_zero(date) for date in shift_days_list]
# 格式化输入的日期为"月日"格式
result = f"{current_data.month}月{current_data.day}日"
# 如果日期在调休列表中,返回True(是工作日)
if result in shift_days_list:
return True
# 如果日期在假期列表中或为周末,返回False(不是工作日)
elif (result in holidays_list) or (current_data.weekday() in [5, 6]):
return False
# 其他情况返回True(是工作日)
else:
return True
# 移除日期字符串中的前导零
def remove_leading_zero(self, date_str):
# 分割月份和日期部分
month, day = date_str.split('月')
# 移除月份前面的零
month = month.lstrip('0')
# 移除日期末尾的"日"字符
day = day.rstrip('日')
# 移除日期前面的零
day = day.lstrip('0')
# 返回处理后的日期字符串
return f'{month}月{day}日'
# 定时任务:每天晙21点自动补全当天缺失的餐饮数据,再自动确认
def cron_fill_today_missing(self):
@@ -296,18 +241,18 @@ class YuthonCatering(models.Model):
# 发送通用提醒消息
conf_records = self.env['yuthon.catering.conf'].search([])
employees = conf_records.mapped('employee_ids')
for employee in employees:
if employee.user_id: # 确保员工有关联的用户
# 构造跳转URL,格式为 f'https://phone.thtzjt.com/phone/Restaurant/(users_id)
users_id = employee.user_id.id
target_url = f'https://phone.thtzjt.com/phone/Restaurant/{users_id}'
# 发送消息,使用指定的格式
if hasattr(self.env["wecom.apps"], 'sync_send_message_textcard'):
description = f"您有1条待办未处理,请及时登OA系统处理,谢谢配合"
title = "餐饮登记提醒"
self.env["wecom.apps"].sync_send_message_textcard(
category='oa',
user_id=employee.wecom_userid if hasattr(employee, 'wecom_userid') else employee.user_id.login,
@@ -343,8 +288,6 @@ class YuthonCatering(models.Model):
'lunch': True,
})
def batch_confirm_catering(self):
records = self.env['yuthon.catering'].browse(self._context.get('active_ids', []))
records.write({
@@ -468,3 +411,10 @@ class YuthonCatering(models.Model):
self.write({
'state': 'confirmed'
})
def remove_leading_zero(self, date_str):
month, day = date_str.split('月')
month = month.lstrip('0')
day = day.rstrip('日')
day = day.lstrip('0')
return f'{month}月{day}日'