35 lines
1.9 KiB
Python
35 lines
1.9 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')]):
|
|
str = 'https://www.thtzjt.com/web#id={}&cids=1&menu_id={}&action={}&model=yuthon.notice&view_type=form'.format(
|
|
record.notice_id.id, menu_id.id, menu_id.action.id)
|
|
data = "您有待确认的通知公告请确认\n" + "<a href=\"{}\">{}</a>".format(str, self.name)
|
|
record.sudo().env["wecom.apps"].sync_send_message(record.employee_id.wecom_userid, data)
|
|
|
|
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', '=', '我的通知公告')])
|
|
str = 'https://www.thtzjt.com/web#id={}&cids=1&menu_id={}&action={}&model=yuthon.notice&view_type=form'.format(
|
|
rec.notice_id.id, menu_id.id, menu_id.action.id)
|
|
data = "您有待确认的通知公告请尽快确认\n" + "<a href=\"{}\">{}</a>".format(str, rec.notice_id.name)
|
|
rec.sudo().env["wecom.apps"].sync_send_message(rec.employee_id.wecom_userid, data)
|