单已下发通知
This commit is contained in:
@@ -30,5 +30,9 @@
|
|||||||
<field name="name">坯料发料提醒</field>
|
<field name="name">坯料发料提醒</field>
|
||||||
<field name="model">stock.picking</field>
|
<field name="model">stock.picking</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="bussiness_mrp_workorder_remind" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">工单已下发通知</field>
|
||||||
|
<field name="model">mrp.workorder</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -23,16 +23,23 @@ class SFMessageStockPicking(models.Model):
|
|||||||
contents = []
|
contents = []
|
||||||
product_id = []
|
product_id = []
|
||||||
for message_queue_id in message_queue_ids:
|
for message_queue_id in message_queue_ids:
|
||||||
|
i = 0
|
||||||
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
|
||||||
stock_picking_line = self.env['stock.picking'].search([('id', '=', int(message_queue_id.res_id))])
|
stock_picking_line = self.env['stock.picking'].search([('id', '=', int(message_queue_id.res_id))])
|
||||||
stock_picking_info = self.env['stock.picking'].search(
|
mrp_production_info = self.env['mrp.production'].search(
|
||||||
[('product_id', '=', stock_picking_line.product_id.id), ('state', '=', 'assigned'),
|
[('name', '=', stock_picking_line.origin)])
|
||||||
('check_in', '=', 'PC')])
|
mrp_production_list = self.env['mrp.production'].search(
|
||||||
if stock_picking_info and stock_picking_info.product_id.id not in product_id:
|
[('product_id', '=', mrp_production_info.product_id.id)])
|
||||||
content = content.replace('{{product_id}}', stock_picking_info.product_id.name)
|
for mrp_production_line in mrp_production_list:
|
||||||
content = content.replace('{{number}}', str(len(stock_picking_info)))
|
picking_ids = mrp_production_line.picking_ids
|
||||||
product_id.append(stock_picking_info.product_id.id)
|
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)
|
contents.append(content)
|
||||||
else:
|
else:
|
||||||
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)
|
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ class SfMessageTemplate(models.Model):
|
|||||||
res.append('sf.functional.tool.assembly')
|
res.append('sf.functional.tool.assembly')
|
||||||
res.append('sf.functional.tool.dismantle')
|
res.append('sf.functional.tool.dismantle')
|
||||||
res.append('purchase.order')
|
res.append('purchase.order')
|
||||||
|
res.append('mrp.workorder')
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -3,4 +3,28 @@ from odoo import models, fields, api, _
|
|||||||
|
|
||||||
class SFMessageWork(models.Model):
|
class SFMessageWork(models.Model):
|
||||||
_name = 'mrp.workorder'
|
_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
|
||||||
|
|||||||
Reference in New Issue
Block a user