消息模版初始化添加相关模版

This commit is contained in:
jinling.yang
2024-09-29 15:24:28 +08:00
parent ccdcd01372
commit 47feb4cf3c
6 changed files with 61 additions and 31 deletions

View File

@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
# from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model): class ResProductMo(models.Model):

View File

@@ -14,7 +14,7 @@
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock'], 'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock'],
'data': [ 'data': [
'data/bussiness_node.xml', 'data/bussiness_node.xml',
'data/cron_data.xml', # 'data/cron_data.xml',
'data/template_data.xml', 'data/template_data.xml',
], ],

View File

@@ -1,6 +1,32 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<odoo> <odoo>
<data noupdate="1"> <data noupdate="1">
<record id="template_pending_order" model="jikimo.message.template">
<field name="name">待接单</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="model">sale.order</field>
<field name="bussiness_node_id" ref="bussiness_pending_order"/>
<field name="msgtype">markdown</field>
<field name="urgency">normal</field>
<field name="content">### 待接单提醒:
单号:销售订单[{{name}}]({{url}})
事项:请确认是否接单。
</field>
</record>
<record id="template_to_be_confirm" model="jikimo.message.template">
<field name="name">确认接单</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="model">sale.order</field>
<field name="bussiness_node_id" ref="bussiness_to_be_confirm"/>
<field name="msgtype">markdown</field>
<field name="urgency">normal</field>
<field name="content">### 待排程提醒:
单号:产品[{{product_id}}]({{url}})
事项:{{mrp_production_count}}个制造订单待计划排程
</field>
</record>
<record id="template_material_purchase_remind" model="jikimo.message.template"> <record id="template_material_purchase_remind" model="jikimo.message.template">
<field name="name">坯料采购提醒</field> <field name="name">坯料采购提醒</field>
<field name="model_id" ref="purchase.model_purchase_order"/> <field name="model_id" ref="purchase.model_purchase_order"/>

View File

@@ -41,30 +41,34 @@ class SFMessageSale(models.Model):
# 继承并重写jikimo.message.dispatch的_get_message() # 继承并重写jikimo.message.dispatch的_get_message()
def _get_message(self, message_queue_ids): def _get_message(self, message_queue_ids):
res = super(SFMessageSale, self)._get_message(message_queue_ids) contents = []
new_res = [] url = self.env['ir.config_parameter'].get_param('web.base.url')
processed_messages = set() # 用于跟踪已经处理过的消息
for item in message_queue_ids: for item in message_queue_ids:
if item.message_template_id.bussiness_node_id.name == '确认接单': # 待接单的处理
if item.message_template_id.bussiness_node_id.name == '待接单':
content = super(SFMessageSale, self)._get_message(item)
action_id = self.env.ref('sale.action_quotations_with_onboarding').id
url = f"{url}/web#id={item.res_id}view_type=form&action={action_id}"
content = content[0].replace('{{url}}', url)
contents.append(content)
# 确认接单的处理
elif item.message_template_id.bussiness_node_id.name == '确认接单':
content = super(SFMessageSale, self)._get_message(item)
sale_order_line = self.env['sale.order.line'].search([('order_id', '=', int(item.res_id))]) sale_order_line = self.env['sale.order.line'].search([('order_id', '=', int(item.res_id))])
if len(sale_order_line) == 1: product = sale_order_line[0].product_id.name if len(sale_order_line) == 1 else '%s...' % \
product = sale_order_line[0].product_id.name sale_order_line[
elif len(sale_order_line) > 1: 0].product_id.name
product = '%s...' % sale_order_line[0].product_id.name action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
for message in res: url = f"{url}/web#view_type=list&action={action_id}"
message_text = message.replace('{{product_id}}', product) content = content[0].replace('{{product_id}}', product).replace('{{url}}', url)
if message_text not in processed_messages: contents.append(content)
new_res.append(message_text) return contents
processed_messages.add(message_text)
if new_res:
res = new_res
return res
# 销售订单逾期预警 # # 销售订单逾期预警
def _overdue_warning_func(self): # def _overdue_warning_func(self):
sale_order_ # sale_order_
return 1 # return 1
#
# 销售订单已逾期 # # 销售订单已逾期
def _overdue_func(self): # def _overdue_func(self):
return 1 # return 1

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests import requests
from odoo import http from odoo import http
from odoo.http import request from odoo.http import request
# from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError

View File

@@ -6,8 +6,8 @@ import os
from datetime import datetime from datetime import datetime
from stl import mesh from stl import mesh
# from OCC.Core.GProp import GProp_GProps # from OCC.Core.GProp import GProp_GProps
# from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file from OCC.Extend.DataExchange import write_stl_file
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_resource_path from odoo.modules import get_resource_path