消息提醒

This commit is contained in:
guanhuan
2024-12-24 14:49:17 +08:00
parent 88f3155132
commit 78eea6aad0
11 changed files with 68 additions and 40 deletions

View File

@@ -69,25 +69,16 @@ 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:
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
unique_products_contents = self.get_production_info(content, unique_products, 'confirmed',
'sf_plan.sf_production_plan_action1')
action_id)
contents.extend(unique_products_contents)
if technology_to_confirmed:
action_id = self.env.ref('mrp.mrp_production_action').id
technology_to_confirmed_contents = self.get_production_info(content, technology_to_confirmed,
'technology_to_confirmed',
'mrp.mrp_production_action')
action_id)
contents.extend(technology_to_confirmed_contents)
logging.info('生产完工入库提醒: %s' % contents)
return contents
@@ -100,7 +91,6 @@ class SFMessageMrpProduction(models.Model):
[('product_id', '=', products_id), ('state', '=', state)])
if production_num >= 1:
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
action_id = self.env.ref(action_id).id
url_with_id = f"{url}/web#view_type=list&action={action_id}"
new_content = (content.replace('{{name}}', product_name)
.replace('{{url}}', url_with_id)
@@ -120,17 +110,3 @@ 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.ref('mrp.menu_mrp_root').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