解决冲突
This commit is contained in:
@@ -10,3 +10,6 @@ from . import sf_message_functional_tool_dismantle
|
||||
from . import sf_message_mrp_production
|
||||
from . import sf_message_quality_cnc_test
|
||||
from . import sf_message_maintenance_logs
|
||||
from . import sf_message_mrp_production_wizard
|
||||
from . import sf_message_mrp_production_adjust_wizard
|
||||
from . import sf_message_product
|
||||
|
||||
@@ -14,19 +14,24 @@ class SFMessageMrpProduction(models.Model):
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing')
|
||||
def _compute_state(self):
|
||||
super(SFMessageMrpProduction, self)._compute_state()
|
||||
for record in self:
|
||||
if record.state in ['scrap', 'done']:
|
||||
# 查询制造订单下的所有未完成的生产订单
|
||||
mrp_production = record.env['mrp.production'].search(
|
||||
[('origin', '=', record.origin), ('state', 'not in', ['scrap', 'done'])])
|
||||
if not mrp_production:
|
||||
mrp_production_queue = self.env["jikimo.message.queue"].search([('res_id', '=', record.id)])
|
||||
if not mrp_production_queue:
|
||||
record.add_queue('生产完工入库提醒')
|
||||
try:
|
||||
for record in self:
|
||||
if record.state in ['scrap', 'done']:
|
||||
# 查询制造订单下的所有未完成的生产订单
|
||||
mrp_production = record.env['mrp.production'].search(
|
||||
[('origin', '=', record.origin), ('state', 'not in', ['scrap', 'done'])])
|
||||
if not mrp_production:
|
||||
mrp_production_queue = self.env["jikimo.message.queue"].search([('res_id', '=', record.id)])
|
||||
if not mrp_production_queue:
|
||||
record.add_queue('生产完工入库提醒')
|
||||
except Exception as e:
|
||||
logging.info('add_queue生产完工入库提醒 error:%s' % e)
|
||||
|
||||
# 获取发送消息内容
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
unique_products = set()
|
||||
technology_to_confirmed = set()
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '生产完工入库提醒':
|
||||
content = message_queue_id.message_template_id.content
|
||||
@@ -40,15 +45,65 @@ class SFMessageMrpProduction(models.Model):
|
||||
content = content.replace('{{name}}', stock_picking_sfp.name).replace(
|
||||
'{{sale_order_name}}', mrp_production.origin).replace('{{request_url}}', url)
|
||||
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))])
|
||||
technology_to_confirmed.add(mrp_production.product_id.id)
|
||||
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 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))])
|
||||
mrp_production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', mrp_production.product_id.id)])
|
||||
mrp_production_names = mrp_production_list.mapped('name')
|
||||
stock_picking_num = self.env['stock.picking'].sudo().search_count(
|
||||
[('origin', 'in', mrp_production_names), ('state', '=', 'assigned')])
|
||||
if stock_picking_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_ready').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(
|
||||
'{{num}}', str(stock_picking_num))
|
||||
contents.append(content)
|
||||
if unique_products:
|
||||
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
|
||||
unique_products_contents = self.get_production_info(content, unique_products, 'confirmed',
|
||||
action_id)
|
||||
contents.extend(unique_products_contents)
|
||||
if technology_to_confirmed:
|
||||
action_id = self.env.ref('mrp.mrp_production_action').id
|
||||
technology_to_confirmed_contents = self.get_production_info(content, technology_to_confirmed,
|
||||
'technology_to_confirmed',
|
||||
action_id)
|
||||
contents.extend(technology_to_confirmed_contents)
|
||||
logging.info('生产完工入库提醒: %s' % contents)
|
||||
return contents, message_queue_ids
|
||||
|
||||
def get_production_info(self, content, product_ids, state, action_id):
|
||||
contents = []
|
||||
for products_id in product_ids:
|
||||
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', '=', state)])
|
||||
if production_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
new_content = (content.replace('{{name}}', product_name)
|
||||
.replace('{{url}}', url_with_id)
|
||||
.replace('{{production_num}}', str(production_num)))
|
||||
contents.append(new_content)
|
||||
return contents
|
||||
|
||||
def request_url(self, id):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_all').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
|
||||
# 查询参数
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'mrp.production',
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'mrp.production',
|
||||
'view_type': 'form'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
|
||||
17
sf_message/models/sf_message_mrp_production_adjust_wizard.py
Normal file
17
sf_message/models/sf_message_mrp_production_adjust_wizard.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import logging
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class SFMessageMrpProductionAdjustWizard(models.TransientModel):
|
||||
_name = 'sf.production.technology.re_adjust.wizard'
|
||||
_description = "制造订单工艺调整"
|
||||
_inherit = ['sf.production.technology.re_adjust.wizard', 'jikimo.message.dispatch']
|
||||
|
||||
def confirm(self):
|
||||
super(SFMessageMrpProductionAdjustWizard, self).confirm()
|
||||
try:
|
||||
for production_info in self.production_id:
|
||||
if production_info.state == 'technology_to_confirmed':
|
||||
production_info.add_queue('待确认加工路线')
|
||||
except Exception as e:
|
||||
logging.info('add_queue待确认加工路线 error:%s' % e)
|
||||
23
sf_message/models/sf_message_mrp_production_wizard.py
Normal file
23
sf_message/models/sf_message_mrp_production_wizard.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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):
|
||||
productions = super(SFMessageMrpProductionWizard, self).confirm()
|
||||
try:
|
||||
for production_info in self.production_id:
|
||||
if production_info.state == 'confirmed' and production_info.product_id.categ_id.type == '成品':
|
||||
production_info.add_queue('待排程')
|
||||
for production_id in productions:
|
||||
workorder_ids = production_id.workorder_ids.filtered(
|
||||
lambda p: p.routing_type == '表面工艺' and p.state != 'cancel')
|
||||
for workorder_id in workorder_ids:
|
||||
purchase_orders_id = workorder_id._get_surface_technics_purchase_ids()
|
||||
purchase_orders_id.add_queue('工序外协采购单通知')
|
||||
except Exception as e:
|
||||
logging.info('add_queue待排程 error:%s' % e)
|
||||
45
sf_message/models/sf_message_product.py
Normal file
45
sf_message/models/sf_message_product.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessagePlan(models.Model):
|
||||
_name = 'product.product'
|
||||
_inherit = ['product.product', 'jikimo.message.dispatch']
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '工单已下发通知':
|
||||
content = message_queue_id.message_template_id.content
|
||||
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||
mrp_production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', product_product.id)])
|
||||
production_num = 0
|
||||
for mrp_production_info in mrp_production_list:
|
||||
routing_type = '人工线下加工' if mrp_production_info.production_type == '人工线下加工' else '装夹预调'
|
||||
mrp_production_ready = mrp_production_info.workorder_ids.filtered(
|
||||
lambda w: w.routing_type == routing_type and w.state == 'ready')
|
||||
if mrp_production_ready:
|
||||
production_num += 1
|
||||
if production_num >= 1:
|
||||
url = self.get_request_url()
|
||||
content = content.replace('{{product_id}}', product_product.name).replace(
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def get_request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
@@ -8,20 +8,62 @@ class SFMessagePurchase(models.Model):
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
process_outsourcing = set()
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '坯料采购提醒':
|
||||
if message_queue_id.message_template_id.name in (
|
||||
'坯料采购提醒', '委外加工采购单提醒', '外购订单采购单提醒'):
|
||||
content = message_queue_id.message_template_id.content
|
||||
url = self.request_url(int(message_queue_id.res_id))
|
||||
purchase_order_line = self.env['purchase.order'].search([('id', '=', int(message_queue_id.res_id))])
|
||||
content = content.replace('{{name}}', purchase_order_line.name).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
if message_queue_id.message_template_id.name == '工序外协采购单通知':
|
||||
content = message_queue_id.message_template_id.content
|
||||
purchase_order_line = self.env['purchase.order'].sudo().search(
|
||||
[('id', '=', int(message_queue_id.res_id))])
|
||||
mrp_production = self.env['mrp.production'].sudo().search([('name', '=', purchase_order_line.origin)])
|
||||
process_outsourcing.add(mrp_production.product_id.id)
|
||||
if message_queue_id.message_template_id.name in ('采购订单预警提醒', '采购单已逾期提醒'):
|
||||
content = message_queue_id.message_template_id.content
|
||||
if message_queue_id.message_template_id.name == '采购订单预警提醒':
|
||||
domain = [('delivery_warning', '=', 'warning')]
|
||||
action_id = self.env.ref("sf_message.purchase_form_warning_action").id
|
||||
else:
|
||||
domain = [('delivery_warning', '=', 'overdue')]
|
||||
action_id = self.env.ref("sf_message.purchase_form_overdue_action").id
|
||||
purchase_order_num = self.env['purchase.order'].sudo().search_count(domain)
|
||||
if purchase_order_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
menu_id = self.env.ref('purchase.menu_purchase_form_action').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}&menu_id={menu_id}"
|
||||
content = content.replace('{{url}}', url_with_id).replace('{{num}}', str(purchase_order_num))
|
||||
contents.append(content)
|
||||
if process_outsourcing:
|
||||
content_info = content
|
||||
for products_id in process_outsourcing:
|
||||
production_num = 0
|
||||
product_name = self.env['product.product'].sudo().search([('id', '=', products_id)]).name
|
||||
production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', products_id), ('state', '=', 'confirmed')])
|
||||
for production_info in production_list:
|
||||
workorder_ids = len(production_info.workorder_ids.filtered(
|
||||
lambda p: p.routing_type == '表面工艺' and p.state != 'cancel'))
|
||||
production_num += workorder_ids
|
||||
if production_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('purchase.purchase_form_action').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('{{num}}', str(production_num)))
|
||||
contents.append(new_content)
|
||||
return contents, message_queue_ids
|
||||
|
||||
def request_url(self, id):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('purchase.purchase_form_action').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_website_payment')]).id
|
||||
menu_id = self.env.ref('purchase.menu_purchase_form_action').id
|
||||
# 查询参数
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id,
|
||||
'model': 'purchase.order',
|
||||
@@ -31,3 +73,27 @@ class SFMessagePurchase(models.Model):
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def _overdue_or_warning_func(self):
|
||||
last_overdue_order, last_warning_order = super(SFMessagePurchase, self)._overdue_or_warning_func()
|
||||
if last_overdue_order:
|
||||
business_node_id = self.env.ref('sf_message.template_purchase_order_overdue').id
|
||||
purchase_order_has = self._get_message_queue(business_node_id)
|
||||
if not purchase_order_has:
|
||||
last_overdue_order.add_queue("采购单已逾期提醒")
|
||||
if last_warning_order:
|
||||
business_node_id = self.env.ref('sf_message.template_purchase_order_warning').id
|
||||
purchase_order_has = self._get_message_queue(business_node_id)
|
||||
if not purchase_order_has:
|
||||
last_warning_order.add_queue("采购订单预警提醒")
|
||||
|
||||
def _get_message_queue(self, business_node_id):
|
||||
message_template = self.env["jikimo.message.template"].sudo().search([
|
||||
("model", "=", self._name),
|
||||
("bussiness_node_id", "=", business_node_id)
|
||||
], limit=1)
|
||||
purchase_order_has = self.env['jikimo.message.queue'].sudo().search([
|
||||
('message_status', '=', 'pending'),
|
||||
('message_template_id', '=', message_template.id)
|
||||
])
|
||||
return purchase_order_has
|
||||
|
||||
@@ -8,17 +8,6 @@ class SFMessageSale(models.Model):
|
||||
_name = 'sale.order'
|
||||
_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):
|
||||
res = super(SFMessageSale, self).action_confirm()
|
||||
@@ -29,19 +18,34 @@ class SFMessageSale(models.Model):
|
||||
purchase_order_id = []
|
||||
if picking_ids:
|
||||
for picking_id in picking_ids:
|
||||
picking_id.add_queue('待确认加工路线')
|
||||
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.move_orig_ids.purchase_line_id.order_id).ids
|
||||
purchase_order_id.extend(purchase_order_ids)
|
||||
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:
|
||||
purchase_order_info.add_queue('坯料采购提醒')
|
||||
purchase_order_ids = self.order_line.purchase_line_ids.order_id | self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id
|
||||
for purchase_order_id in purchase_order_ids:
|
||||
if purchase_order_id.purchase_type == 'outsourcing':
|
||||
purchase_order_id.add_queue('委外加工采购单提醒')
|
||||
if purchase_order_id.purchase_type == 'standard':
|
||||
purchase_order_id.add_queue('外购订单采购单提醒')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
logging.info('action_confirm res:%s' % 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()
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
@@ -53,9 +57,11 @@ class SFMessageSale(models.Model):
|
||||
time_range = timedelta(minutes=2)
|
||||
i = 0
|
||||
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)
|
||||
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}"
|
||||
content = content[0].replace('{{url}}', url_with_id)
|
||||
contents.append(content)
|
||||
|
||||
@@ -12,26 +12,44 @@ class SFMessageStockPicking(models.Model):
|
||||
@api.model_create_multi
|
||||
def create(self, vals):
|
||||
result = super(SFMessageStockPicking, self).create(vals)
|
||||
for obj in result:
|
||||
if obj.location_id.name == '进货' and obj.location_dest_id.name == '刀具房':
|
||||
obj.add_queue('调拨入库')
|
||||
try:
|
||||
for obj in result:
|
||||
if obj.location_id.name == '进货' and obj.location_dest_id.name == '刀具房':
|
||||
obj.add_queue('调拨入库')
|
||||
except Exception as e:
|
||||
logging.info('add_queue调拨入库 error:%s' % e)
|
||||
return result
|
||||
|
||||
@api.depends('move_type', 'immediate_transfer', 'move_ids.state', 'move_ids.picking_id')
|
||||
def _compute_state(self):
|
||||
super(SFMessageStockPicking, self)._compute_state()
|
||||
for record in self:
|
||||
if record.state == 'assigned' and record.check_in == 'PC':
|
||||
record.add_queue('坯料发料提醒')
|
||||
try:
|
||||
for record in self:
|
||||
if (record.state == 'assigned' and record.picking_type_id.sequence_code == 'PC'
|
||||
and record.product_id.categ_id.type == '坯料'):
|
||||
record.add_queue('坯料发料提醒')
|
||||
|
||||
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
|
||||
stock_picking_sfp = record.env['stock.picking'].search(
|
||||
[('origin', '=', record.origin), ('state', '!=', 'done'),
|
||||
('picking_type_id.sequence_code', '=', 'SFP')])
|
||||
if not stock_picking_sfp:
|
||||
stock_picking_send = self.env["jikimo.message.queue"].sudo().search([('res_id', '=', record.id)])
|
||||
if not stock_picking_send:
|
||||
record.add_queue('订单发货提醒')
|
||||
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
|
||||
stock_picking_sfp = record.env['stock.picking'].search(
|
||||
[('origin', '=', record.origin), ('state', '!=', 'done'),
|
||||
('picking_type_id.sequence_code', '=', 'SFP')])
|
||||
if not stock_picking_sfp:
|
||||
stock_picking_send = self.env["jikimo.message.queue"].sudo().search(
|
||||
[('res_id', '=', record.id)])
|
||||
if not stock_picking_send:
|
||||
record.add_queue('订单发货提醒')
|
||||
if record.picking_type_id.sequence_code == 'OCOUT' and record.state == 'assigned':
|
||||
mrp_production = self.env['mrp.production'].sudo().search([('name', '=', record.origin)])
|
||||
production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', mrp_production.product_id.id)])
|
||||
manufacturing_order_names = production_list.mapped('name')
|
||||
stock_picking_list = self.env['stock.picking'].sudo().search(
|
||||
[('origin', 'in', manufacturing_order_names), ('picking_type_id.sequence_code', '=', 'OCOUT')])
|
||||
all_ready_or_done = all(picking.state in ['assigned', 'done'] for picking in stock_picking_list)
|
||||
if all_ready_or_done:
|
||||
mrp_production.add_queue('工序外协发料通知')
|
||||
except Exception as e:
|
||||
logging.info('add_queue_compute_state error:%s' % e)
|
||||
|
||||
def deal_stock_picking_sfp(self, message_queue_id): # 处理订单发货提醒
|
||||
content = None
|
||||
@@ -49,27 +67,18 @@ class SFMessageStockPicking(models.Model):
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
product_id = []
|
||||
for message_queue_id in message_queue_ids:
|
||||
i = 0
|
||||
if message_queue_id.message_template_id.name == '坯料发料提醒':
|
||||
content = message_queue_id.message_template_id.content
|
||||
stock_picking_line = self.env['stock.picking'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||
mrp_production_info = self.env['mrp.production'].sudo().search(
|
||||
[('name', '=', stock_picking_line.origin)])
|
||||
mrp_production_list = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', mrp_production_info.product_id.id)])
|
||||
for mrp_production_line in mrp_production_list:
|
||||
picking_ids = mrp_production_line.picking_ids
|
||||
for picking_id in picking_ids:
|
||||
if picking_id.state == 'assigned' and picking_id.check_in == 'PC':
|
||||
i += 1
|
||||
if i > 0 and mrp_production_info.product_id.id not in product_id:
|
||||
url = self.request_url()
|
||||
content = content.replace('{{product_id}}', mrp_production_info.product_id.name).replace(
|
||||
'{{number}}', str(i)).replace('{{request_url}}', url)
|
||||
product_id.append(mrp_production_info.product_id.id)
|
||||
contents.append(content)
|
||||
stock_picking_line = self.env['stock.picking'].sudo().search(
|
||||
[('id', '=', int(message_queue_id.res_id))])
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
||||
menu_id = self.env.ref('stock.menu_stock_root').id
|
||||
url_with_id = f"{url}/web#view_type=form&action={action_id}&menu_id={menu_id}&id={stock_picking_line.id}"
|
||||
content = content.replace('{{name}}', stock_picking_line.name).replace(
|
||||
'{{request_url}}', url_with_id)
|
||||
contents.append(content)
|
||||
elif message_queue_id.message_template_id.name == '订单发货提醒':
|
||||
content = self.deal_stock_picking_sfp(message_queue_id)
|
||||
if content:
|
||||
@@ -86,19 +95,6 @@ class SFMessageStockPicking(models.Model):
|
||||
else:
|
||||
return super(SFMessageStockPicking, self).get_special_url(id, tmplate_name, special_name, model_id)
|
||||
|
||||
def request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.stock_picking_type_action').id
|
||||
menu_id = self.env['ir.model.data'].sudo().search([('name', '=', 'module_theme_treehouse')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking',
|
||||
'view_type': 'kanban'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def request_url1(self, id):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_all').id
|
||||
|
||||
@@ -16,4 +16,6 @@ class SfMessageTemplate(models.Model):
|
||||
res.append('mrp.workorder')
|
||||
res.append('sf.maintenance.logs')
|
||||
res.append('quality.cnc.test')
|
||||
res.append('mrp.production')
|
||||
res.append('product.product')
|
||||
return res
|
||||
|
||||
@@ -12,19 +12,30 @@ class SFMessageWork(models.Model):
|
||||
_name = 'mrp.workorder'
|
||||
_inherit = ['mrp.workorder', 'jikimo.message.dispatch']
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids.state', 'production_id.tool_state')
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||
'production_id.programming_state')
|
||||
def _compute_state(self):
|
||||
super(SFMessageWork, self)._compute_state()
|
||||
for workorder in self:
|
||||
if workorder.state == 'ready' and workorder.routing_type == '装夹预调':
|
||||
min_sequence_wk = None
|
||||
work_ids = workorder.production_id.workorder_ids.filtered(lambda w: w.routing_type == '装夹预调')
|
||||
if work_ids:
|
||||
min_sequence_wk = work_ids.sorted(key=lambda w: w.sequence)[0]
|
||||
if (
|
||||
workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id) or (
|
||||
workorder.state == 'ready' and workorder.routing_type == '人工线下加工'):
|
||||
message_template = self.env["jikimo.message.template"].sudo().search(
|
||||
[("name", "=", '工单已下发通知')], limit=1)
|
||||
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
|
||||
[('res_id', '=', workorder.id), ("message_status", "=", "pending")])
|
||||
[('res_id', '=', workorder.production_id.product_id.id),
|
||||
("message_status", "in", ("pending", "sent")),
|
||||
('message_template_id', '=', message_template.id)])
|
||||
if not jikimo_message_queue:
|
||||
workorder.add_queue('工单已下发通知')
|
||||
workorder.production_id.product_id.add_queue('工单已下发通知')
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
product_id = []
|
||||
bussiness_node = None
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
@@ -37,20 +48,7 @@ class SFMessageWork(models.Model):
|
||||
}
|
||||
i = 0
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '工单已下发通知':
|
||||
content = message_queue_id.message_template_id.content
|
||||
mrp_workorder_line = self.env['mrp.workorder'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||
mrp_workorder_list = self.env['mrp.workorder'].sudo().search(
|
||||
[('product_id', '=', mrp_workorder_line.product_id.id), ('state', '=', 'ready'),
|
||||
('routing_type', '=', '装夹预调')])
|
||||
if len(mrp_workorder_list) > 0 and mrp_workorder_line.product_id.id not in product_id:
|
||||
url = self.request_url()
|
||||
content = content.replace('{{product_id}}', mrp_workorder_line.product_id.name).replace(
|
||||
'{{number}}', str(len(mrp_workorder_list))).replace(
|
||||
'{{request_url}}', url)
|
||||
product_id.append(mrp_workorder_line.product_id.id)
|
||||
contents.append(content)
|
||||
elif message_queue_id.message_template_id.name in template_names['预警'] + template_names['已逾期']:
|
||||
if message_queue_id.message_template_id.name in template_names['预警'] + template_names['已逾期']:
|
||||
item = message_queue_id.message_template_id
|
||||
bussiness_node = item.bussiness_node_id.name
|
||||
for reminder_time in item.reminder_time_ids:
|
||||
@@ -95,20 +93,6 @@ class SFMessageWork(models.Model):
|
||||
contents.append(content)
|
||||
return contents, message_queue_ids
|
||||
|
||||
def request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
menu_id = self.env['ir.model.data'].sudo().search([('name', '=', 'module_stock_dropshipping')]).id
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def _overdue_or_warning_func(self):
|
||||
workorders = self.env['mrp.workorder'].search(
|
||||
[("state", "in", ["ready", "progress", "to be detected"]), ('schedule_state', '=', '已排')])
|
||||
|
||||
Reference in New Issue
Block a user