Accept Merge Request #1873: (feature/合同审批 -> develop)

Merge Request: 修复坯料发料提醒重复发送

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1873
This commit is contained in:
管欢
2025-02-27 09:54:51 +08:00
committed by Coding

View File

@@ -30,7 +30,9 @@ class SFMessageStockPicking(models.Model):
for record in self:
if (record.state == 'assigned' and record.picking_type_id.sequence_code == 'PC'
and record.product_id.categ_id.type == '坯料'):
record.add_queue('坯料发料提醒')
jikimo_message_queue = record.get_message_queue(record.id)
if not jikimo_message_queue:
record.add_queue('坯料发料提醒')
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
stock_picking_sfp = record.env['stock.picking'].search(
@@ -129,3 +131,14 @@ class SFMessageStockPicking(models.Model):
# 拼接URL
full_url = url + "/web#" + query_string
return full_url
def get_message_queue(self, res_id):
business_node_id = self.env.ref('sf_message.bussiness_material_picking_remind').id
message_template = self.env["jikimo.message.template"].sudo().search([
("model", "=", self._name),
("bussiness_node_id", "=", business_node_id)
], limit=1)
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
[('res_id', '=', res_id), ("message_status", "in", ("pending", "sent")),
('message_template_id', '=', message_template.id)])
return jikimo_message_queue