39 lines
2.6 KiB
Python
39 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models, tools
|
|
from odoo.exceptions import UserError, ValidationError
|
|
|
|
|
|
class YuthonConfirmUsers(models.Model):
|
|
_name = "yuthon.confirm.users"
|
|
_description = "公告确认信息"
|
|
|
|
employee_id = fields.Many2one('hr.employee', string='员工')
|
|
notice_id = fields.Many2one('yuthon.notice', string="公告名称")
|
|
notice_code = fields.Char(string="公告编号")
|
|
notice_name = fields.Char(string="公告名称")
|
|
state = fields.Selection([('no', '未确认'), ('yes', '已确认')], string="状态")
|
|
|
|
def sync_confirm_users_notices(self):
|
|
menu_id = self.env['ir.ui.menu'].search([('name', '=', '通知公告')])
|
|
for record in self.search([('state', '=', 'no')]):
|
|
partner_ids = record.employee_id.user_id.partner_id.id
|
|
record.with_context(lang=record.env.lang)._message_auto_subscribe_notify(partner_ids, 'yuthon_notice.message_yuthon_confirm_users_data')
|
|
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.notice&view_type=list&menu_id={menu_id.id}'
|
|
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='notice', user_id=record.employee_id.wecom_userid, title="通知公告",
|
|
description="您有待确认的通知公告请尽快确认", url=url, btntxt="详细信息")
|
|
|
|
def reminders_notice(self):
|
|
for rem in self:
|
|
if rem.state == 'yes':
|
|
raise UserError('已确认不可催办')
|
|
confirm_noice_ids = self.env["yuthon.confirm.users"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
|
for rec in confirm_noice_ids:
|
|
menu_id = self.env['ir.ui.menu'].search([('name', '=', '通知公告')])
|
|
url = f'https://oa.thtzjt.com/web#id={self.id}&cids=2&action={menu_id.action.id}&model=yuthon.notice&view_type=list&menu_id={menu_id.id}'
|
|
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='notice', user_id=rec.employee_id.wecom_userid,
|
|
title="通知公告(催办)", description="您有待确认的通知公告请尽快确认",
|
|
url=url, btntxt="详细信息")
|
|
partner_ids = rec.employee_id.user_id.partner_id.id
|
|
rec.with_context(lang=rec.env.lang)._message_auto_subscribe_notify(partner_ids,
|
|
'yuthon_notice.message_yuthon_confirm_users_data')
|