待质检提醒
This commit is contained in:
@@ -519,6 +519,7 @@
|
|||||||
<field name="name">Quality Checks</field>
|
<field name="name">Quality Checks</field>
|
||||||
<field name="res_model">quality.check</field>
|
<field name="res_model">quality.check</field>
|
||||||
<field name="view_mode">tree,kanban,form,pivot,graph</field>
|
<field name="view_mode">tree,kanban,form,pivot,graph</field>
|
||||||
|
<field name="context">{'is_web_request': True}</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
No quality check found
|
No quality check found
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp',
|
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp',
|
||||||
'sf_manufacturing','product'],
|
'sf_manufacturing','product','quality'],
|
||||||
'data': [
|
'data': [
|
||||||
'data/bussiness_node.xml',
|
'data/bussiness_node.xml',
|
||||||
'data/cron_data.xml',
|
'data/cron_data.xml',
|
||||||
|
|||||||
@@ -150,5 +150,10 @@
|
|||||||
<field name="name">采购单已逾期提醒</field>
|
<field name="name">采购单已逾期提醒</field>
|
||||||
<field name="model">purchase.order</field>
|
<field name="model">purchase.order</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="bussiness_quality_check" model="jikimo.message.bussiness.node">
|
||||||
|
<field name="name">待质检提醒</field>
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -389,5 +389,17 @@
|
|||||||
事项:[共有{{num}}个采购订单已逾期]({{url}})
|
事项:[共有{{num}}个采购订单已逾期]({{url}})
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="template_quality_check" model="jikimo.message.template">
|
||||||
|
<field name="name">待质检提醒</field>
|
||||||
|
<field name="model_id" ref="product.model_product_product"/>
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
<field name="bussiness_node_id" ref="bussiness_quality_check"/>
|
||||||
|
<field name="msgtype">markdown</field>
|
||||||
|
<field name="urgency">normal</field>
|
||||||
|
<field name="content">### 待质检提醒:
|
||||||
|
单号:产品[{{name}}]({{url}})
|
||||||
|
事项:有{{num}}个质检单需要处理。</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -13,3 +13,4 @@ from . import sf_message_maintenance_logs
|
|||||||
from . import sf_message_mrp_production_wizard
|
from . import sf_message_mrp_production_wizard
|
||||||
from . import sf_message_mrp_production_adjust_wizard
|
from . import sf_message_mrp_production_adjust_wizard
|
||||||
from . import sf_message_product
|
from . import sf_message_product
|
||||||
|
from . import sf_message_quality_check
|
||||||
@@ -3,7 +3,7 @@ from odoo import models, fields, api, _
|
|||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
|
||||||
class SFMessagePlan(models.Model):
|
class SFMessageProduct(models.Model):
|
||||||
_name = 'product.product'
|
_name = 'product.product'
|
||||||
_inherit = ['product.product', 'jikimo.message.dispatch']
|
_inherit = ['product.product', 'jikimo.message.dispatch']
|
||||||
|
|
||||||
@@ -28,6 +28,18 @@ class SFMessagePlan(models.Model):
|
|||||||
'{{number}}', str(production_num)).replace(
|
'{{number}}', str(production_num)).replace(
|
||||||
'{{request_url}}', url)
|
'{{request_url}}', url)
|
||||||
contents.append(content)
|
contents.append(content)
|
||||||
|
if message_queue_id.message_template_id.name == '待质检提醒':
|
||||||
|
content = message_queue_id.message_template_id.content
|
||||||
|
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||||
|
quality_check_num = self.env['quality.check'].sudo().search_count(
|
||||||
|
[('product_id', '=', product_product.id), ('quality_state', '=', 'none')])
|
||||||
|
if quality_check_num >= 1:
|
||||||
|
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
action_id = self.env.ref('quality_control.quality_check_action_report').id
|
||||||
|
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||||
|
content = content.replace('{{name}}', product_product.name).replace('{{url}}', url_with_id).replace(
|
||||||
|
'{{num}}', str(quality_check_num))
|
||||||
|
contents.append(content)
|
||||||
return contents, message_queue_ids
|
return contents, message_queue_ids
|
||||||
|
|
||||||
def get_request_url(self):
|
def get_request_url(self):
|
||||||
|
|||||||
34
sf_message/models/sf_message_quality_check.py
Normal file
34
sf_message/models/sf_message_quality_check.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class SFMessageQualityCheck(models.Model):
|
||||||
|
_name = 'quality.check'
|
||||||
|
_inherit = ['quality.check', 'jikimo.message.dispatch']
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
result = super().create(vals_list)
|
||||||
|
try:
|
||||||
|
# 判断是否为web页面创建请求
|
||||||
|
is_web_request = self.env.context.get('is_web_request', False)
|
||||||
|
if not is_web_request:
|
||||||
|
for obj in result:
|
||||||
|
jikimo_message_queue = self.get_message_queue(obj.product_id.id)
|
||||||
|
if not jikimo_message_queue:
|
||||||
|
obj.product_id.add_queue('待质检提醒')
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('add_queue待质检提醒 error:%s' % e)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def get_message_queue(self, res_id):
|
||||||
|
business_node_id = self.env.ref('sf_message.bussiness_quality_check').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
|
||||||
Reference in New Issue
Block a user