消息提醒
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp'],
|
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp','sf_manufacturing'],
|
||||||
'data': [
|
'data': [
|
||||||
'data/bussiness_node.xml',
|
'data/bussiness_node.xml',
|
||||||
'data/cron_data.xml',
|
'data/cron_data.xml',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
|
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
|
||||||
|
from odoo.addons.sf_bf_connect.controllers.controllers import Sf_Bf_Connect
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@@ -58,3 +59,18 @@ class MessageSfMrsConnect(Sf_Mrs_Connect):
|
|||||||
res = {'code': 400, 'message': '设备故障信息推送失败', 'error': str(e)}
|
res = {'code': 400, 'message': '设备故障信息推送失败', 'error': str(e)}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|
||||||
|
class MessageSfBfConnect(Sf_Bf_Connect):
|
||||||
|
@http.route('/api/bfm_process_order/list', type='http', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_bfm_process_order_list(self, **kw):
|
||||||
|
res = super(MessageSfBfConnect, self).get_bfm_process_order_list(**kw)
|
||||||
|
response_data = json.loads(res.data.decode('utf-8'))
|
||||||
|
if response_data['status'] == 1:
|
||||||
|
try:
|
||||||
|
_logger.info('已进入待接单消息推送:%s' % response_data)
|
||||||
|
sale_order = request.env['sale.order'].sudo().search([('name', '=', response_data['factory_order_no'])])
|
||||||
|
sale_order.add_queue('待接单')
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('add_queue error:%s' % e)
|
||||||
|
return res
|
||||||
|
|||||||
@@ -22,6 +22,15 @@
|
|||||||
<field name="model">sale.order</field>
|
<field name="model">sale.order</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_supply_method" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">待确认供货方式</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_technology_to_confirmed" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">待确认加工路线</field>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="transfer_inventory" model="jikimo.message.bussiness.node">
|
<record id="transfer_inventory" model="jikimo.message.bussiness.node">
|
||||||
<field name="name">调拨入库</field>
|
<field name="name">调拨入库</field>
|
||||||
@@ -106,5 +115,10 @@
|
|||||||
<field name="name">设备故障</field>
|
<field name="name">设备故障</field>
|
||||||
<field name="model">sf.maintenance.logs</field>
|
<field name="model">sf.maintenance.logs</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_state_draft" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">待排程</field>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<field name="msgtype">markdown</field>
|
<field name="msgtype">markdown</field>
|
||||||
<field name="urgency">normal</field>
|
<field name="urgency">normal</field>
|
||||||
<field name="content">### 待接单提醒:
|
<field name="content">### 待接单提醒:
|
||||||
单号:销售订单[{{name}}]({{url}})
|
单号:询价单[{{name}}]({{url}})
|
||||||
事项:请确认是否接单。
|
事项:请确认是否接单。
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -275,5 +275,44 @@
|
|||||||
机台号:[{{maintenance_equipment_id.name}}]({{url}})
|
机台号:[{{maintenance_equipment_id.name}}]({{url}})
|
||||||
事项:{{create_date}}故障报警</field>
|
事项:{{create_date}}故障报警</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="template_supply_method" 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_supply_method"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 待确认供货方式提醒:
|
||||||
|
单号:销售订单[{{name}}]({{url}})
|
||||||
|
事项:请确认供货方式。
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="template_technology_to_confirmed" model="jikimo.message.template">
|
||||||
|
<field name="name">待确认加工路线</field>
|
||||||
|
<field name="model_id" ref="mrp.model_mrp_production"/>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_technology_to_confirmed"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 待确认加工路线提醒:
|
||||||
|
单号:产品[{{name}}]({{url}})
|
||||||
|
事项:有{{production_num}}个制造订单需要确认加工路线。
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="template_state_draft" model="jikimo.message.template">
|
||||||
|
<field name="name">待排程</field>
|
||||||
|
<field name="model_id" ref="mrp.model_mrp_production"/>
|
||||||
|
<field name="model">mrp.production</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_state_draft"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 待排程提醒:
|
||||||
|
单号:产品[{{name}}]({{url}})
|
||||||
|
事项:有{{production_num}}个制造订单待排程。
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -10,3 +10,4 @@ from . import sf_message_functional_tool_dismantle
|
|||||||
from . import sf_message_mrp_production
|
from . import sf_message_mrp_production
|
||||||
from . import sf_message_quality_cnc_test
|
from . import sf_message_quality_cnc_test
|
||||||
from . import sf_message_maintenance_logs
|
from . import sf_message_maintenance_logs
|
||||||
|
from . import sf_message_mrp_production_wizard
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class SFMessageMrpProduction(models.Model):
|
|||||||
# 获取发送消息内容
|
# 获取发送消息内容
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
contents = []
|
contents = []
|
||||||
|
unique_products = set()
|
||||||
for message_queue_id in message_queue_ids:
|
for message_queue_id in message_queue_ids:
|
||||||
if message_queue_id.message_template_id.name == '生产完工入库提醒':
|
if message_queue_id.message_template_id.name == '生产完工入库提醒':
|
||||||
content = message_queue_id.message_template_id.content
|
content = message_queue_id.message_template_id.content
|
||||||
@@ -40,6 +41,37 @@ class SFMessageMrpProduction(models.Model):
|
|||||||
content = content.replace('{{name}}', stock_picking_sfp.name).replace(
|
content = content.replace('{{name}}', stock_picking_sfp.name).replace(
|
||||||
'{{sale_order_name}}', mrp_production.origin).replace('{{request_url}}', url)
|
'{{sale_order_name}}', mrp_production.origin).replace('{{request_url}}', url)
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
|
if message_queue_id.message_template_id.name == '待确认加工路线':
|
||||||
|
content = message_queue_id.message_template_id.content
|
||||||
|
mrp_production = self.env['mrp.production'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||||
|
production_num = self.env['mrp.production'].sudo().search_count(
|
||||||
|
[('product_id', '=', mrp_production.product_id.id), ('state', '=', 'technology_to_confirmed')])
|
||||||
|
if production_num >= 1:
|
||||||
|
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
action_id = self.env.ref('mrp.mrp_production_action').id
|
||||||
|
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||||
|
content = (content.replace('{{name}}', mrp_production.product_id.name)
|
||||||
|
.replace('{{url}}', url_with_id)
|
||||||
|
.replace('{{production_num}}', str(production_num)))
|
||||||
|
contents.append(content)
|
||||||
|
if message_queue_id.message_template_id.name == '待排程':
|
||||||
|
content = message_queue_id.message_template_id.content
|
||||||
|
mrp_production = self.env['mrp.production'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||||
|
unique_products.add(mrp_production.product_id.id)
|
||||||
|
if unique_products:
|
||||||
|
content_info = content
|
||||||
|
for products_id in unique_products:
|
||||||
|
product_name = self.env['product.product'].sudo().search([('id', '=', products_id)]).name
|
||||||
|
production_num = self.env['mrp.production'].sudo().search_count(
|
||||||
|
[('product_id', '=', products_id), ('state', '=', 'confirmed')])
|
||||||
|
if production_num >= 1:
|
||||||
|
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
|
||||||
|
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||||
|
new_content = (content_info.replace('{{name}}', product_name)
|
||||||
|
.replace('{{url}}', url_with_id)
|
||||||
|
.replace('{{production_num}}', str(production_num)))
|
||||||
|
contents.append(new_content)
|
||||||
logging.info('生产完工入库提醒: %s' % contents)
|
logging.info('生产完工入库提醒: %s' % contents)
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
|
|||||||
17
sf_message/models/sf_message_mrp_production_wizard.py
Normal file
17
sf_message/models/sf_message_mrp_production_wizard.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import logging
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class SFMessageMrpProductionWizard(models.TransientModel):
|
||||||
|
_name = 'sf.production.technology.wizard'
|
||||||
|
_description = "制造订单工艺确认向导"
|
||||||
|
_inherit = ['sf.production.technology.wizard', 'jikimo.message.dispatch']
|
||||||
|
|
||||||
|
def confirm(self):
|
||||||
|
super(SFMessageMrpProductionWizard, self).confirm()
|
||||||
|
try:
|
||||||
|
for production_info in self.production_id:
|
||||||
|
if production_info.state == 'confirmed':
|
||||||
|
production_info.add_queue('待排程')
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('add_queue待排程 error:%s' % e)
|
||||||
@@ -8,17 +8,6 @@ class SFMessageSale(models.Model):
|
|||||||
_name = 'sale.order'
|
_name = 'sale.order'
|
||||||
_inherit = ['sale.order', 'jikimo.message.dispatch']
|
_inherit = ['sale.order', 'jikimo.message.dispatch']
|
||||||
|
|
||||||
@api.model_create_multi
|
|
||||||
def create(self, vals_list):
|
|
||||||
res = super(SFMessageSale, self).create(vals_list)
|
|
||||||
if res:
|
|
||||||
try:
|
|
||||||
logging.info('add_queue res:%s' % res)
|
|
||||||
res.add_queue('待接单')
|
|
||||||
except Exception as e:
|
|
||||||
logging.info('add_queue error:%s' % e)
|
|
||||||
return res
|
|
||||||
|
|
||||||
# 确认接单
|
# 确认接单
|
||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
res = super(SFMessageSale, self).action_confirm()
|
res = super(SFMessageSale, self).action_confirm()
|
||||||
@@ -27,21 +16,36 @@ class SFMessageSale(models.Model):
|
|||||||
self.add_queue('确认接单')
|
self.add_queue('确认接单')
|
||||||
picking_ids = self.mrp_production_ids
|
picking_ids = self.mrp_production_ids
|
||||||
purchase_order_id = []
|
purchase_order_id = []
|
||||||
|
unique_products = set()
|
||||||
if picking_ids:
|
if picking_ids:
|
||||||
for picking_id in picking_ids:
|
for picking_id in picking_ids:
|
||||||
|
unique_products.add(picking_id.product_id.id)
|
||||||
purchase_order_ids = (
|
purchase_order_ids = (
|
||||||
picking_id.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
picking_id.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||||
picking_id.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids
|
picking_id.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids
|
||||||
purchase_order_id.extend(purchase_order_ids)
|
purchase_order_id.extend(purchase_order_ids)
|
||||||
if purchase_order_id:
|
if purchase_order_id:
|
||||||
purchase_order_list = self.env['purchase.order'].sudo().search([('id', 'in', purchase_order_id)])
|
purchase_order_list = self.env['purchase.order'].sudo().search(
|
||||||
|
[('id', 'in', purchase_order_id)])
|
||||||
for purchase_order_info in purchase_order_list:
|
for purchase_order_info in purchase_order_list:
|
||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
|
if unique_products:
|
||||||
|
for product_id in unique_products:
|
||||||
|
production_info = self.env['mrp.production'].sudo().search(
|
||||||
|
[('product_id', '=', product_id)], limit=1, order='id')
|
||||||
|
production_info.add_queue('待确认加工路线')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('add_queue error:%s' % e)
|
logging.info('add_queue error:%s' % e)
|
||||||
logging.info('action_confirm res:%s' % res)
|
logging.info('action_confirm res:%s' % res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def confirm_to_supply_method(self):
|
||||||
|
super(SFMessageSale, self).confirm_to_supply_method()
|
||||||
|
try:
|
||||||
|
self.add_queue('待确认供货方式')
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('add_queue待确认供货方式 error:%s' % e)
|
||||||
|
|
||||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
contents = []
|
contents = []
|
||||||
@@ -53,9 +57,11 @@ class SFMessageSale(models.Model):
|
|||||||
time_range = timedelta(minutes=2)
|
time_range = timedelta(minutes=2)
|
||||||
i = 0
|
i = 0
|
||||||
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 in ('待接单', '待确认供货方式'):
|
||||||
content = super(SFMessageSale, self)._get_message(item)
|
content = super(SFMessageSale, self)._get_message(item)
|
||||||
action_id = self.env.ref('sale.action_quotations_with_onboarding').id
|
action_id = self.env.ref('sale.action_quotations_with_onboarding').id \
|
||||||
|
if item.message_template_id.bussiness_node_id.name == '待接单' \
|
||||||
|
else self.env.ref('sale.action_orders').id
|
||||||
url_with_id = f"{url}/web#id={item.res_id}&view_type=form&action={action_id}"
|
url_with_id = f"{url}/web#id={item.res_id}&view_type=form&action={action_id}"
|
||||||
content = content[0].replace('{{url}}', url_with_id)
|
content = content[0].replace('{{url}}', url_with_id)
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
|
|||||||
Reference in New Issue
Block a user