消息模版初始化添加相关模版
This commit is contained in:
@@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.modules import get_resource_path
|
||||
|
||||
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
|
||||
|
||||
class ResProductMo(models.Model):
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock'],
|
||||
'data': [
|
||||
'data/bussiness_node.xml',
|
||||
'data/cron_data.xml',
|
||||
# 'data/cron_data.xml',
|
||||
'data/template_data.xml',
|
||||
|
||||
],
|
||||
|
||||
@@ -1,6 +1,32 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<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">
|
||||
<field name="name">坯料采购提醒</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||
|
||||
@@ -41,30 +41,34 @@ class SFMessageSale(models.Model):
|
||||
|
||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||
def _get_message(self, message_queue_ids):
|
||||
res = super(SFMessageSale, self)._get_message(message_queue_ids)
|
||||
new_res = []
|
||||
processed_messages = set() # 用于跟踪已经处理过的消息
|
||||
contents = []
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
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))])
|
||||
if len(sale_order_line) == 1:
|
||||
product = sale_order_line[0].product_id.name
|
||||
elif len(sale_order_line) > 1:
|
||||
product = '%s...' % sale_order_line[0].product_id.name
|
||||
for message in res:
|
||||
message_text = message.replace('{{product_id}}', product)
|
||||
if message_text not in processed_messages:
|
||||
new_res.append(message_text)
|
||||
processed_messages.add(message_text)
|
||||
if new_res:
|
||||
res = new_res
|
||||
return res
|
||||
product = sale_order_line[0].product_id.name if len(sale_order_line) == 1 else '%s...' % \
|
||||
sale_order_line[
|
||||
0].product_id.name
|
||||
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
|
||||
url = f"{url}/web#view_type=list&action={action_id}"
|
||||
content = content[0].replace('{{product_id}}', product).replace('{{url}}', url)
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
# 销售订单逾期预警
|
||||
def _overdue_warning_func(self):
|
||||
sale_order_
|
||||
return 1
|
||||
|
||||
# 销售订单已逾期
|
||||
def _overdue_func(self):
|
||||
return 1
|
||||
# # 销售订单逾期预警
|
||||
# def _overdue_warning_func(self):
|
||||
# sale_order_
|
||||
# return 1
|
||||
#
|
||||
# # 销售订单已逾期
|
||||
# def _overdue_func(self):
|
||||
# return 1
|
||||
|
||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
||||
import requests
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
@@ -6,8 +6,8 @@ import os
|
||||
from datetime import datetime
|
||||
from stl import mesh
|
||||
# from OCC.Core.GProp import GProp_GProps
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
|
||||
Reference in New Issue
Block a user