消息提醒

This commit is contained in:
guanhuan
2024-12-19 14:36:16 +08:00
parent 5eda4427df
commit 72bf8ad011
7 changed files with 84 additions and 77 deletions

View File

@@ -14,15 +14,18 @@ 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):
@@ -66,6 +69,17 @@ class SFMessageMrpProduction(models.Model):
url_with_id).replace(
'{{num}}', str(stock_picking_num))
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))])
production_num = self.env['mrp.production'].sudo().search_count(
[('product_id', '=', mrp_production.product_id.id)])
if production_num >= 1:
url = self.get_request_url()
content = content.replace('{{product_id}}', mrp_production.product_id.name).replace(
'{{number}}', str(production_num)).replace(
'{{request_url}}', url)
contents.append(content)
if unique_products:
unique_products_contents = self.get_production_info(content, unique_products, 'confirmed',
'sf_plan.sf_production_plan_action1')
@@ -106,3 +120,17 @@ class SFMessageMrpProduction(models.Model):
# 拼接URL
full_url = url + "/web#" + query_string
return full_url
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['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