消息提醒
This commit is contained in:
@@ -116,3 +116,4 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
if workorder[0].state in ['pending']:
|
if workorder[0].state in ['pending']:
|
||||||
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
workorder[0].state = 'waiting'
|
workorder[0].state = 'waiting'
|
||||||
|
return productions
|
||||||
|
|||||||
@@ -120,5 +120,20 @@
|
|||||||
<field name="name">待排程</field>
|
<field name="name">待排程</field>
|
||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_outsourcing" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">委外加工采购单提醒</field>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_purchase" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">外购订单采购单提醒</field>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_process_outsourcing" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">工序外协采购单通知</field>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -314,5 +314,41 @@
|
|||||||
事项:有{{production_num}}个制造订单待排程。
|
事项:有{{production_num}}个制造订单待排程。
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="template_outsourcing_remind" model="jikimo.message.template">
|
||||||
|
<field name="name">委外加工采购单提醒</field>
|
||||||
|
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_outsourcing"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 委外加工采购通知:
|
||||||
|
单号:委外加工采购单[{{name}}]({{request_url}})
|
||||||
|
事项:请确认委外采购单并处理。</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="template_purchase_remind" model="jikimo.message.template">
|
||||||
|
<field name="name">外购订单采购单提醒</field>
|
||||||
|
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_purchase"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 外购订单采购通知:
|
||||||
|
单号:外购采购单[{{name}}]({{request_url}})
|
||||||
|
事项:请确认外购采购单并处理。</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="template_process_outsourcing_remind" model="jikimo.message.template">
|
||||||
|
<field name="name">工序外协采购单通知</field>
|
||||||
|
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||||
|
<field name="model">purchase.order</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_process_outsourcing"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 工序外协采购单通知:
|
||||||
|
单号:工序外协采购单产品[{{name}}]({{url}})
|
||||||
|
事项:有{{num}}个工序外协采购单需要确认。</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -8,10 +8,16 @@ class SFMessageMrpProductionWizard(models.TransientModel):
|
|||||||
_inherit = ['sf.production.technology.wizard', 'jikimo.message.dispatch']
|
_inherit = ['sf.production.technology.wizard', 'jikimo.message.dispatch']
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
super(SFMessageMrpProductionWizard, self).confirm()
|
productions = super(SFMessageMrpProductionWizard, self).confirm()
|
||||||
try:
|
try:
|
||||||
for production_info in self.production_id:
|
for production_info in self.production_id:
|
||||||
if production_info.state == 'confirmed':
|
if production_info.state == 'confirmed':
|
||||||
production_info.add_queue('待排程')
|
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:
|
except Exception as e:
|
||||||
logging.info('add_queue待排程 error:%s' % e)
|
logging.info('add_queue待排程 error:%s' % e)
|
||||||
|
|||||||
@@ -8,14 +8,41 @@ class SFMessagePurchase(models.Model):
|
|||||||
|
|
||||||
def _get_message(self, message_queue_ids):
|
def _get_message(self, message_queue_ids):
|
||||||
contents = []
|
contents = []
|
||||||
|
process_outsourcing = 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 in (
|
||||||
|
'坯料采购提醒', '委外加工采购单提醒', '外购订单采购单提醒'):
|
||||||
content = message_queue_id.message_template_id.content
|
content = message_queue_id.message_template_id.content
|
||||||
url = self.request_url(int(message_queue_id.res_id))
|
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))])
|
purchase_order_line = self.env['purchase.order'].search([('id', '=', int(message_queue_id.res_id))])
|
||||||
content = content.replace('{{name}}', purchase_order_line.name).replace(
|
content = content.replace('{{name}}', purchase_order_line.name).replace(
|
||||||
'{{request_url}}', url)
|
'{{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
|
||||||
|
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 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
|
return contents
|
||||||
|
|
||||||
def request_url(self, id):
|
def request_url(self, id):
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ class SFMessageSale(models.Model):
|
|||||||
[('id', 'in', purchase_order_id)])
|
[('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('坯料采购提醒')
|
||||||
|
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 == 'consignment':
|
||||||
|
purchase_order_id.add_queue('委外加工采购单提醒')
|
||||||
|
if purchase_order_id.purchase_type == 'standard':
|
||||||
|
purchase_order_id.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)
|
||||||
|
|||||||
Reference in New Issue
Block a user