pengyuthon wechat
This commit is contained in:
@@ -104,7 +104,7 @@ class SoongWorkflow(models.Model):
|
||||
@api.depends('start_date', 'end_date')
|
||||
def compute_is_enable(self):
|
||||
for rec in self:
|
||||
if rec.start_date and rec.end_date:
|
||||
if rec.start_date and rec.end_date and self.name:
|
||||
if rec.start_date <= fields.Date.today() < rec.end_date:
|
||||
is_enable_ids = self.search([('model_id', '=', self.model_id.id), ('is_enable', '=', True)])
|
||||
if len(is_enable_ids) <= 1:
|
||||
|
||||
@@ -85,7 +85,7 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
url = "https://oa.thtzjt.com/mail/view?model={}&res_id={}".format(self.res_model, record_id.id)
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa',
|
||||
user_id=employee.wecom_userid,
|
||||
title="审批抄送提醒",
|
||||
title=record_id.name + "审批抄送提醒",
|
||||
description="您有新的抄送提醒请及时查看",
|
||||
url=url, btntxt="详细信息")
|
||||
# 转交逻辑--单线
|
||||
@@ -98,7 +98,7 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
url = 'https://oa.thtzjt.com/mail/view?model={}&res_id={}'.format(self.res_model, self.res_id)
|
||||
for employee in self.employee_ids:
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=employee.wecom_userid,
|
||||
title=self.name,
|
||||
title=record_id.name,
|
||||
description="您有新的审批单请及时处理",
|
||||
url=url, btntxt="详情")
|
||||
return self.node_btn_id.with_context(cx).run()
|
||||
@@ -107,7 +107,7 @@ class SoongWorkflowCommentWizard(models.TransientModel):
|
||||
url = 'https://oa.thtzjt.com/mail/view?model={}&res_id={}'.format(self.res_model, self.res_id)
|
||||
for employee in self.employee_ids:
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='oa', user_id=employee.wecom_userid,
|
||||
title=self.name,
|
||||
title=record_id.name,
|
||||
description="您的审批单已被退回,请查看详情",
|
||||
url=url, btntxt="详情")
|
||||
return self.node_btn_id.with_context(cx).run()
|
||||
|
||||
@@ -108,17 +108,6 @@ class YuthonLesseeNotice(models.Model):
|
||||
data = "您有新的通知公告请及时确认\n" + "<a href=\"{}\">{}</a>".format(str, self.name)
|
||||
we_id = self.env['hr.employee'].search([('id', '=', user)]).wecom_userid
|
||||
self.sudo().env["wecom.apps"].sync_send_message(we_id, data)
|
||||
# # 待办关联
|
||||
# self.env['project.task'].create({
|
||||
# 'name': '新的通知公告' + self.name + "请及时确认",
|
||||
# 'user_ids': [(4, user)],
|
||||
# 'notice_origin_id': self.id,
|
||||
# })
|
||||
|
||||
# 普通用户权限是否打开,可能需要配置权限
|
||||
# 关联待办和不关联待办
|
||||
# partner_ids = self.sudo().env['res.users'].search([('id', 'in', publish_user_list)]).mapped('partner_id').ids
|
||||
# self.sudo().with_context(lang=self.env.lang)._message_auto_subscribe_notify(partner_ids, 'yuthon_notice.message_yuthon_confirm_users_data')
|
||||
self.write({"notice_state": 'yes'})
|
||||
|
||||
def look_up_notice_users(self):
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<field name="department_id" column_invisible="1"/>
|
||||
<field name="company_page" column_invisible="1"/>
|
||||
<field name="create_date"/>
|
||||
<field name="start_date" />
|
||||
<field name="end_date" />
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="is_notice_roger" string="状态"/>
|
||||
<button name="on_sequence" string="置顶" invisible="sequence != 0" type="object" class="btn-primary"/>
|
||||
<button name="no_sequence" string="取消置顶" invisible="sequence != 1" type="object"
|
||||
@@ -30,22 +30,22 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="公告管理">
|
||||
<header>
|
||||
<button name="notice_publish" string="发布" type="object" class="btn-primary"/>
|
||||
<button name="notice_publish" string="发布" type="object" class="btn-primary"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group col="3">
|
||||
<group>
|
||||
<field name="company_page" string="发布公司"/>
|
||||
<field name="notice_type_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="department_id" string="发布部门"/>
|
||||
<field name="create_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_id" required="1"/>
|
||||
<field name="is_notice_roger"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="company_page" string="发布公司"/>
|
||||
<field name="notice_type_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="department_id" string="发布部门"/>
|
||||
<field name="create_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_id" required="1"/>
|
||||
<field name="is_notice_roger"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
@@ -54,15 +54,15 @@
|
||||
</group>
|
||||
<group col="3">
|
||||
<group>
|
||||
<field name="department_ids" widget="many2many_tags"/>
|
||||
<field name="department_ids" widget="many2many_tags"/>
|
||||
<field name="is_change_notice"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="is_sticky"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="users_role_ids" widget="many2many_tags"/>
|
||||
<field name="users_role_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
@@ -100,7 +100,7 @@
|
||||
<field name="model">yuthon.lessee.notice</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="公告管理" create="false" edit="false" delete="false">
|
||||
<field name="user_id" string="发布人"/>
|
||||
<field name="user_id" string="发布人"/>
|
||||
<field name="notice_type_id" string="类型"/>
|
||||
<field name="name"/>
|
||||
<field name="department_id" column_invisible="1"/>
|
||||
@@ -129,7 +129,7 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="department_ids" widget="many2many_tags"/>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
<field name="employee_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="read_number"/>
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
<field name="padding">3</field>
|
||||
</record>
|
||||
|
||||
<!-- <template id="message_yuthon_confirm_users_data">-->
|
||||
<!-- <p style="margin: 0px;">-->
|
||||
<!-- <span>尊敬的用户,</span><br />-->
|
||||
<!-- <span style="margin-top: 8px;">您有一条新的公告确认请求-->
|
||||
<!-- <t t-esc="object.name"/> 请登录系统查看详情。-->
|
||||
<!-- </span>-->
|
||||
<!-- </p>-->
|
||||
<!-- <p style="margin-top: 24px; margin-bottom: 16px;">-->
|
||||
<!-- <a t-att-href="access_link" t-att-data-oe-model="object._name" t-att-data-oe-id="object.id" style="background-color:#2C65F7; padding: 10px; text-decoration: none; color: #fff; border-radius: 5px;">-->
|
||||
<!-- 查看 <t t-esc="model_description or 'document'"/>-->
|
||||
<!-- </a>-->
|
||||
<!-- </p>-->
|
||||
<!-- </template>-->
|
||||
<template id="message_yuthon_confirm_users_data">
|
||||
<p style="margin: 0px;">
|
||||
<span>尊敬的用户,</span><br />
|
||||
<span style="margin-top: 8px;">您有一条新的公告确认请求
|
||||
<t t-esc="object.name"/> 请登录系统查看详情。
|
||||
</span>
|
||||
</p>
|
||||
<p style="margin-top: 24px; margin-bottom: 16px;">
|
||||
<a t-att-href="access_link" t-att-data-oe-model="object._name" t-att-data-oe-id="object.id" style="background-color:#2C65F7; padding: 10px; text-decoration: none; color: #fff; border-radius: 5px;">
|
||||
查看 <t t-esc="model_description or 'document'"/>
|
||||
</a>
|
||||
</p>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo.exceptions import ValidationError, UserError
|
||||
class YuthonNotice(models.Model):
|
||||
_name = "yuthon.notice"
|
||||
_description = '通知公告'
|
||||
_inherit = ['soong.workflow.mixin']
|
||||
_inherit = ['mail.thread.main.attachment', 'mail.activity.mixin', 'soong.workflow.mixin']
|
||||
_rec_name = 'name'
|
||||
_order = "sequence desc"
|
||||
|
||||
@@ -21,7 +21,8 @@ class YuthonNotice(models.Model):
|
||||
end_date = fields.Date(string="终止日期")
|
||||
sequence = fields.Integer(string="顺序", default=1, compute='_compute_sequence')
|
||||
employee_ids = fields.Many2many('hr.employee', string="人员范围")
|
||||
notice_state = fields.Selection([('no', '未发布'), ('yes', '已发布'), ('stop', '已终止')], default='no', string="公告状态")
|
||||
notice_state = fields.Selection([('no', '未发布'), ('yes', '已发布'), ('stop', '已终止')], default='no',
|
||||
string="公告状态")
|
||||
notice_documents_ids = fields.Many2many('documents.document', string="附件")
|
||||
is_notice_roger = fields.Selection([('yes', '已读'), ('no', '未读')], default='no', string="确认状态")
|
||||
is_change_notice = fields.Boolean(string="是否发送通知", default=True)
|
||||
@@ -34,7 +35,8 @@ class YuthonNotice(models.Model):
|
||||
|
||||
@api.depends('read_number')
|
||||
def _compute_read_number(self):
|
||||
notice_confirm_ids = self.env['yuthon.confirm.users'].search([('notice_id.id', '=', self.id), ('state', '=', 'yes')])
|
||||
notice_confirm_ids = self.env['yuthon.confirm.users'].search(
|
||||
[('notice_id.id', '=', self.id), ('state', '=', 'yes')])
|
||||
for read in self:
|
||||
if notice_confirm_ids:
|
||||
read.read_number = len(notice_confirm_ids)
|
||||
@@ -43,7 +45,8 @@ class YuthonNotice(models.Model):
|
||||
|
||||
@api.onchange('is_notice_roger')
|
||||
def onchange_is_notice_roger(self):
|
||||
roger_id = self.env['yuthon.confirm.users'].search([('notice_id', '=', self.id), ('employee_id', '=', self.env.user.employee_id.id)])
|
||||
roger_id = self.env['yuthon.confirm.users'].search(
|
||||
[('notice_id', '=', self.id), ('employee_id', '=', self.env.user.employee_id.id)])
|
||||
if not roger_id:
|
||||
self.is_notice_roger = 'yes'
|
||||
|
||||
@@ -78,9 +81,10 @@ class YuthonNotice(models.Model):
|
||||
'state': 'no',
|
||||
})
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='notice', user_id=we_id,
|
||||
title="通知公告",
|
||||
description=self.name,
|
||||
title="通知公告", description=self.name,
|
||||
url=str, btntxt="详细信息")
|
||||
# partner_ids = self.sudo().env['res.users'].search([('id', 'in', employee_users_list)]).mapped('partner_id').ids
|
||||
# self.sudo().with_context(lang=self.env.lang)._message_auto_subscribe_notify(partner_ids, 'yuthon_notice.message_yuthon_confirm_users_data')
|
||||
self.write({"notice_state": 'yes'})
|
||||
|
||||
def look_up_notice_users(self):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from odoo import api, fields, models, modules
|
||||
import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, time
|
||||
|
||||
|
||||
class YuthonWillTask(models.Model):
|
||||
@@ -17,8 +17,8 @@ class YuthonWillTask(models.Model):
|
||||
employee_ids = fields.Many2many('hr.employee', string='人员', default=lambda self: self.env.user.employee_id)
|
||||
remind = fields.Selection([('fifteen', '提醒-15分钟'), ('thirty', '提醒-30分钟'), ('one_hour', '提醒-1小时'),
|
||||
('two_hour', '提醒-2小时'), ('one_day', '提醒-1天')], string='提醒')
|
||||
start_time = fields.Datetime(string='开始时间')
|
||||
end_time = fields.Datetime(string='结束时间')
|
||||
start_time = fields.Datetime(string='开始时间', default=fields.Date.today())
|
||||
end_time = fields.Datetime(string='结束时间', default=lambda self: datetime.combine(datetime.now().date(), time(11, 0, 0)))
|
||||
|
||||
remind_mapping = {
|
||||
'fifteen': timedelta(minutes=15),
|
||||
@@ -40,7 +40,9 @@ class YuthonWillTask(models.Model):
|
||||
if not self.wecom_userid:
|
||||
raise ("请同步{}的企业微信".format(self.name))
|
||||
for employee_id in self.employee_ids:
|
||||
url = "https://oa.thtzjt.com/mail/view?model={}&res_id={}".format(self.yuthon_will_task,employee_id.id)
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='attendance', user_id=self.wecom_userid,
|
||||
url = "https://oa.thtzjt.com/mail/view?model={}&res_id={}".format(self.yuthon_will_task, employee_id.id)
|
||||
self.sudo().env["wecom.apps"].sync_send_message_textcard(category='task', user_id=self.wecom_userid,
|
||||
title="待办事项", description="测试消息请忽略",
|
||||
url=url, btntxt="详细信息")
|
||||
url=url, btntxt="详细信息")
|
||||
|
||||
# odoo本身的消息提醒
|
||||
Reference in New Issue
Block a user