消息通知url修改
This commit is contained in:
@@ -1,6 +1,35 @@
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessagePurchase(models.Model):
|
||||
_name = 'purchase.order'
|
||||
_inherit = ['purchase.order', 'jikimo.message.dispatch']
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '坯料采购提醒':
|
||||
content = message_queue_id.message_template_id.content
|
||||
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))])
|
||||
content = content.replace('{{name}}', purchase_order_line.name).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def request_url(self, id):
|
||||
we_config_info = self.env['we.config'].sudo().search([], limit=1)
|
||||
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
|
||||
full_url = 'https://%s/' % redirect_domain
|
||||
action_id = self.env.ref('purchase.purchase_form_action').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_website_payment')]).id
|
||||
# 查询参数
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id,
|
||||
'model': 'purchase.order',
|
||||
'view_type': 'form'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = full_url + "web#" + query_string
|
||||
return full_url
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessageStockPicking(models.Model):
|
||||
@@ -41,7 +42,7 @@ class SFMessageStockPicking(models.Model):
|
||||
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:
|
||||
url = message_queue_id.message_template_id.get_url(int(message_queue_id.res_id))
|
||||
url = self.request_url()
|
||||
content = content.replace('{{product_id}}', mrp_production_info.product_id.name).replace(
|
||||
'{{number}}', str(i)).replace('{{request_url}}', url)
|
||||
product_id.append(mrp_production_info.product_id.id)
|
||||
@@ -50,3 +51,18 @@ class SFMessageStockPicking(models.Model):
|
||||
else:
|
||||
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)
|
||||
return res
|
||||
|
||||
def request_url(self):
|
||||
we_config_info = self.env['we.config'].sudo().search([], limit=1)
|
||||
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
|
||||
full_url = 'https://%s/' % redirect_domain
|
||||
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking',
|
||||
'view_type': 'list'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = full_url + "web#" + query_string
|
||||
return full_url
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessageWork(models.Model):
|
||||
@@ -10,7 +11,10 @@ class SFMessageWork(models.Model):
|
||||
super(SFMessageWork, self)._compute_state()
|
||||
for workorder in self:
|
||||
if workorder.state == 'ready' and workorder.routing_type == '装夹预调':
|
||||
workorder.add_queue('工单已下发通知')
|
||||
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
|
||||
[('res_id', '=', workorder.id), ("message_status", "=", "pending")])
|
||||
if not jikimo_message_queue:
|
||||
workorder.add_queue('工单已下发通知')
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
@@ -23,12 +27,25 @@ class SFMessageWork(models.Model):
|
||||
[('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:
|
||||
url = message_queue_id.message_template_id.get_url(int(message_queue_id.res_id)) + "&active_id=1"
|
||||
url = self.request_url()
|
||||
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 "").replace(
|
||||
'{{request_url}}', url)
|
||||
product_id.append(mrp_workorder_line.product_id.id)
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def request_url(self):
|
||||
we_config_info = self.env['we.config'].sudo().search([], limit=1)
|
||||
redirect_domain = self.env['we.app'].sudo().search([('id', '=', we_config_info.odoo_app_id.id)]).redirect_domain
|
||||
full_url = 'https://%s/' % redirect_domain
|
||||
action_id = self.env.ref('sf_manufacturing.mrp_workorder_action_tablet').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': 1}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = full_url + "web#" + query_string
|
||||
return full_url
|
||||
|
||||
Reference in New Issue
Block a user