消息提醒
This commit is contained in:
@@ -8,17 +8,6 @@ class SFMessageSale(models.Model):
|
||||
_name = 'sale.order'
|
||||
_inherit = ['sale.order', 'jikimo.message.dispatch']
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super(SFMessageSale, self).create(vals_list)
|
||||
if res:
|
||||
try:
|
||||
logging.info('add_queue res:%s' % res)
|
||||
res.add_queue('待接单')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
return res
|
||||
|
||||
# 确认接单
|
||||
def action_confirm(self):
|
||||
res = super(SFMessageSale, self).action_confirm()
|
||||
@@ -27,21 +16,36 @@ class SFMessageSale(models.Model):
|
||||
self.add_queue('确认接单')
|
||||
picking_ids = self.mrp_production_ids
|
||||
purchase_order_id = []
|
||||
unique_products = set()
|
||||
if picking_ids:
|
||||
for picking_id in picking_ids:
|
||||
unique_products.add(picking_id.product_id.id)
|
||||
purchase_order_ids = (
|
||||
picking_id.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||
picking_id.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids
|
||||
purchase_order_id.extend(purchase_order_ids)
|
||||
if purchase_order_id:
|
||||
purchase_order_list = self.env['purchase.order'].sudo().search([('id', 'in', purchase_order_id)])
|
||||
purchase_order_list = self.env['purchase.order'].sudo().search(
|
||||
[('id', 'in', purchase_order_id)])
|
||||
for purchase_order_info in purchase_order_list:
|
||||
purchase_order_info.add_queue('坯料采购提醒')
|
||||
if unique_products:
|
||||
for product_id in unique_products:
|
||||
production_info = self.env['mrp.production'].sudo().search(
|
||||
[('product_id', '=', product_id)], limit=1, order='id')
|
||||
production_info.add_queue('待确认加工路线')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
logging.info('action_confirm res:%s' % res)
|
||||
return res
|
||||
|
||||
def confirm_to_supply_method(self):
|
||||
super(SFMessageSale, self).confirm_to_supply_method()
|
||||
try:
|
||||
self.add_queue('待确认供货方式')
|
||||
except Exception as e:
|
||||
logging.info('add_queue待确认供货方式 error:%s' % e)
|
||||
|
||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
@@ -53,9 +57,11 @@ class SFMessageSale(models.Model):
|
||||
time_range = timedelta(minutes=2)
|
||||
i = 0
|
||||
for item in message_queue_ids:
|
||||
if item.message_template_id.bussiness_node_id.name == '待接单':
|
||||
if item.message_template_id.bussiness_node_id.name in ('待接单', '待确认供货方式'):
|
||||
content = super(SFMessageSale, self)._get_message(item)
|
||||
action_id = self.env.ref('sale.action_quotations_with_onboarding').id
|
||||
action_id = self.env.ref('sale.action_quotations_with_onboarding').id \
|
||||
if item.message_template_id.bussiness_node_id.name == '待接单' \
|
||||
else self.env.ref('sale.action_orders').id
|
||||
url_with_id = f"{url}/web#id={item.res_id}&view_type=form&action={action_id}"
|
||||
content = content[0].replace('{{url}}', url_with_id)
|
||||
contents.append(content)
|
||||
|
||||
Reference in New Issue
Block a user