From bcc2d4cb21e7c9f2cfccd1bb5799a43215a1cf94 Mon Sep 17 00:00:00 2001 From: pengyuthon Date: Thu, 8 Jan 2026 15:56:42 +0800 Subject: [PATCH] 1 --- yuthon_wechat/models/wecom_apps.py | 8 ++++++++ yuthon_wechat/models/wecom_apps_config.py | 1 + yuthon_will_task/models/yuthon_will_task.py | 9 ++++++++- yuthon_will_task/views/yuthon_will_task_views.xml | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/yuthon_wechat/models/wecom_apps.py b/yuthon_wechat/models/wecom_apps.py index 713202819..5146c2c2a 100644 --- a/yuthon_wechat/models/wecom_apps.py +++ b/yuthon_wechat/models/wecom_apps.py @@ -2,6 +2,7 @@ import logging import json from datetime import datetime, timedelta from odoo import models, fields +import requests _logger = logging.getLogger(__name__) @@ -96,6 +97,13 @@ class WeComApps(models.Model): return True, result_data return False, result_data + def back_message(self, msg_id='', category="default"): + if category == 'task': + token = self.env['wecom.apps'].search([('name', '=', '日程消息通知')])['access_token'] + data = {'msgid': msg_id} + url = f'https://qyapi.weixin.qq.com/cgi-bin/message/recall?access_token={token}' + requests.post(url=url, data=json.dumps(data)) + def sync_send_message_textcard(self, content_item='', touser='', category='default', user_id=None, title="", description="", url="", btntxt="详情"): """ touser 否 成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送 diff --git a/yuthon_wechat/models/wecom_apps_config.py b/yuthon_wechat/models/wecom_apps_config.py index 2ff899c10..09f8d76ba 100644 --- a/yuthon_wechat/models/wecom_apps_config.py +++ b/yuthon_wechat/models/wecom_apps_config.py @@ -19,6 +19,7 @@ class WecomAppsConfig(models.Model): ('login', '登录验证应用'), ('message_send', '发送消息应用'), ('meeting', '会议管理应用'), + ('back_msg', '消息撤回') ], default="default") wecom_apps_category = fields.Selection( string='应用场景', diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py index 7a5e25bf5..0b6c946d0 100644 --- a/yuthon_will_task/models/yuthon_will_task.py +++ b/yuthon_will_task/models/yuthon_will_task.py @@ -81,6 +81,12 @@ class YuthonWillTask(models.Model): employee_id = fields.Many2one('hr.employee', string="经办人", default=lambda self: self.env.user.employee_id) task_week = fields.Char(string="周", readonly=True, compute='_compute_task_week') + msg_id = fields.Char(string="msg_id") + + def back_wecom_msg(self): + # msg_id = 'tbqGFSu3GPn66h1H8k2y_zkyKFwpgq3m05CoDVHxZPQKpANdOlvHw4mYmChfPgH4Xwwse_t6bjOq1-gmNjrGNGu_VhKwxguyym-Q6IkoH5E' + self.env['wecom.apps'].back_message(category='task', msg_id=self.msg_id) + @api.depends('start_date') def _compute_task_week(self): @@ -197,8 +203,9 @@ class YuthonWillTask(models.Model): url = f'https://phone.thtzjt.com/phone/Schedule/{self.id}/{employee_id.id}' self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task', user_id=employee_id.wecom_userid, title="日程事项提醒", description=data, url=url, btntxt="详细信息") - self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task', user_id="18562027762", + test_msg_id = self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task', user_id="18562027762", title="日程事项提醒", description=data, url=url, btntxt="详细信息") + self.write({'msg_id': test_msg_id}) return { 'type': 'ir.actions.client', 'tag': 'display_notification', diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index cee5b9bef..ea2817102 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -25,6 +25,7 @@