单已下发通知

This commit is contained in:
guanhuan
2024-09-24 10:56:23 +08:00
parent 378850682d
commit 36c1c7b170
4 changed files with 44 additions and 8 deletions

View File

@@ -30,5 +30,9 @@
<field name="name">坯料发料提醒</field>
<field name="model">stock.picking</field>
</record>
<record id="bussiness_mrp_workorder_remind" model="jikimo.message.bussiness.node">
<field name="name">工单已下发通知</field>
<field name="model">mrp.workorder</field>
</record>
</data>
</odoo>

View File

@@ -23,16 +23,23 @@ class SFMessageStockPicking(models.Model):
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'].search([('id', '=', int(message_queue_id.res_id))])
stock_picking_info = self.env['stock.picking'].search(
[('product_id', '=', stock_picking_line.product_id.id), ('state', '=', 'assigned'),
('check_in', '=', 'PC')])
if stock_picking_info and stock_picking_info.product_id.id not in product_id:
content = content.replace('{{product_id}}', stock_picking_info.product_id.name)
content = content.replace('{{number}}', str(len(stock_picking_info)))
product_id.append(stock_picking_info.product_id.id)
mrp_production_info = self.env['mrp.production'].search(
[('name', '=', stock_picking_line.origin)])
mrp_production_list = self.env['mrp.production'].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:
content = content.replace('{{product_id}}', mrp_production_info.product_id.name).replace(
'{{number}}', str(i))
product_id.append(mrp_production_info.product_id.id)
contents.append(content)
else:
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)

View File

@@ -13,4 +13,5 @@ class SfMessageTemplate(models.Model):
res.append('sf.functional.tool.assembly')
res.append('sf.functional.tool.dismantle')
res.append('purchase.order')
res.append('mrp.workorder')
return res

View File

@@ -3,4 +3,28 @@ from odoo import models, fields, api, _
class SFMessageWork(models.Model):
_name = 'mrp.workorder'
_inherit = ['mrp.workorder', 'jikimo.message.dispatch']
_inherit = ['mrp.workorder', 'jikimo.message.dispatch']
@api.depends('production_availability', 'blocked_by_workorder_ids.state')
def _compute_state(self):
super(SFMessageWork, self)._compute_state()
if self.state == 'ready' and self.routing_type == '装夹预调':
self.add_queue('工单已下发通知')
def _get_message(self, message_queue_ids):
contents = []
product_id = []
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'].search([('id', '=', int(message_queue_id.res_id))])
mrp_workorder_list = self.env['mrp.workorder'].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:
content = content.replace('{{product_id}}', mrp_workorder_line.product_id.name).replace(
'{{number}}', str(len(mrp_workorder_list))).replace(
'{{part_number}}', mrp_workorder_line.part_number if mrp_workorder_line.part_number else "")
product_id.append(mrp_workorder_line.product_id.id)
contents.append(content)
return contents