工单已下发提醒
This commit is contained in:
@@ -13,8 +13,15 @@ class SFMessagePlan(models.Model):
|
||||
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))])
|
||||
production_num = self.env['mrp.production'].sudo().search_count(
|
||||
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(
|
||||
|
||||
@@ -18,16 +18,21 @@ class SFMessageWork(models.Model):
|
||||
def _compute_state(self):
|
||||
super(SFMessageWork, self)._compute_state()
|
||||
for workorder in self:
|
||||
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:
|
||||
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.production_id.product_id.id), ("message_status", "in", ("pending", "sent")),
|
||||
('message_template_id', '=', message_template.id)])
|
||||
if not jikimo_message_queue:
|
||||
workorder.production_id.product_id.add_queue('工单已下发通知')
|
||||
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.production_id.product_id.id),
|
||||
("message_status", "in", ("pending", "sent")),
|
||||
('message_template_id', '=', message_template.id)])
|
||||
if not jikimo_message_queue:
|
||||
workorder.production_id.product_id.add_queue('工单已下发通知')
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
|
||||
Reference in New Issue
Block a user