From 47feb4cf3c0e6eeaf96bfe99e7fc58662f8a5e92 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Sun, 29 Sep 2024 15:24:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=A8=A1=E7=89=88=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=B7=BB=E5=8A=A0=E7=9B=B8=E5=85=B3=E6=A8=A1?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 +- sf_message/__manifest__.py | 2 +- sf_message/data/template_data.xml | 26 +++++++++++ sf_message/models/sf_message_sale.py | 52 +++++++++++---------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 6 files changed, 61 insertions(+), 31 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index b9f4a4c8..7f4dc2b8 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -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): diff --git a/sf_message/__manifest__.py b/sf_message/__manifest__.py index 421abe40..e767ec2d 100644 --- a/sf_message/__manifest__.py +++ b/sf_message/__manifest__.py @@ -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', ], diff --git a/sf_message/data/template_data.xml b/sf_message/data/template_data.xml index 868b3f52..3033e687 100644 --- a/sf_message/data/template_data.xml +++ b/sf_message/data/template_data.xml @@ -1,6 +1,32 @@ + + + 待接单 + + sale.order + + markdown + normal + ### 待接单提醒: +单号:销售订单[{{name}}]({{url}}) +事项:请确认是否接单。 + + + + + 确认接单 + + sale.order + + markdown + normal + ### 待排程提醒: +单号:产品[{{product_id}}]({{url}}) +事项:{{mrp_production_count}}个制造订单待计划排程 + + 坯料采购提醒 diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py index ca9ce570..18964a8c 100644 --- a/sf_message/models/sf_message_sale.py +++ b/sf_message/models/sf_message_sale.py @@ -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 diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index cb1886a1..081807a4 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -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 diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 9bd61132..4756a2c5 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -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