Compare commits
8 Commits
feature/sa
...
feature/消息
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f1514bd14 | ||
|
|
6b61df9d50 | ||
|
|
d182641d81 | ||
|
|
c6aeff2006 | ||
|
|
eaaa13fb9a | ||
|
|
f92bd8263c | ||
|
|
247bebbd75 | ||
|
|
39ed32f3e9 |
@@ -72,8 +72,30 @@ class jikimo_purchase_tier_validation(models.Model):
|
||||
message_type='notification',
|
||||
subtype_xmlid='mail.mt_note'
|
||||
)
|
||||
res = super(jikimo_purchase_tier_validation, self).request_validation()
|
||||
self.state = 'to approve'
|
||||
return res
|
||||
|
||||
return super(jikimo_purchase_tier_validation, self).request_validation()
|
||||
def restart_validation(self):
|
||||
res = super(jikimo_purchase_tier_validation, self).restart_validation()
|
||||
self.state = 'draft'
|
||||
return res
|
||||
|
||||
def _validate_tier(self, tiers=False):
|
||||
res = super(jikimo_purchase_tier_validation, self)._validate_tier(tiers)
|
||||
self.state = 'approved'
|
||||
return res
|
||||
|
||||
def _rejected_tier(self, tiers=False):
|
||||
res = super(jikimo_purchase_tier_validation, self)._rejected_tier(tiers)
|
||||
self.state = 'draft'
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _get_under_validation_exceptions(self):
|
||||
res = super(jikimo_purchase_tier_validation, self)._get_under_validation_exceptions()
|
||||
res.append("state")
|
||||
return res
|
||||
|
||||
# 上传合同文件
|
||||
def upload_contract_file(self):
|
||||
|
||||
@@ -519,6 +519,7 @@
|
||||
<field name="name">Quality Checks</field>
|
||||
<field name="res_model">quality.check</field>
|
||||
<field name="view_mode">tree,kanban,form,pivot,graph</field>
|
||||
<field name="context">{'is_web_request': True}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
No quality check found
|
||||
|
||||
@@ -605,10 +605,10 @@ class StockPicking(models.Model):
|
||||
sale_info = self.env['sale.order'].sudo().search(
|
||||
[('name', '=', sale_name)])
|
||||
else:
|
||||
production_list = self.env['mrp.production'].sudo().search(
|
||||
sale_order_line = self.env['sale.order.line'].sudo().search(
|
||||
[('product_id', '=', product_id.id)])
|
||||
if production_list:
|
||||
sale_info = production_list[0].sale_order_id
|
||||
if sale_order_line:
|
||||
sale_info = sale_order_line[0].order_id
|
||||
if sale_info:
|
||||
item.sale_order_id = sale_info.id
|
||||
item.retrospect_ref = sale_info.order_code
|
||||
@@ -654,7 +654,10 @@ class StockPicking(models.Model):
|
||||
if self.location_id.name == '成品存货区' and self.location_dest_id.name == '客户':
|
||||
sale_id = self.env['sale.order'].sudo().search(
|
||||
[('name', '=', self.origin)])
|
||||
if sale_id and res:
|
||||
stock_picking_list = self.env['stock.picking'].sudo().search(
|
||||
[('id', 'in', sale_id.picking_ids.ids)])
|
||||
stock_picking = stock_picking_list.filtered(lambda p: p.state not in ("done", "cancel"))
|
||||
if sale_id and not stock_picking:
|
||||
sale_id.write({'state': 'delivered'})
|
||||
return res
|
||||
|
||||
@@ -678,7 +681,7 @@ class StockPicking(models.Model):
|
||||
# 从sorted_workorders中找到上一工单的move
|
||||
if len(sorted_workorders) > 1:
|
||||
move_dest_id = \
|
||||
sorted_workorders[sorted_workorders.index(workorder) + 1].move_subcontract_workorder_ids[1].id
|
||||
sorted_workorders[sorted_workorders.index(workorder) + 1].move_subcontract_workorder_ids[1].id
|
||||
new_picking = True
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
'category': 'sf',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp',
|
||||
'sf_manufacturing','product'],
|
||||
'sf_manufacturing', 'product', 'quality'],
|
||||
'data': [
|
||||
'data/bussiness_node.xml',
|
||||
'data/cron_data.xml',
|
||||
@@ -20,6 +20,7 @@
|
||||
'security/ir.model.access.csv',
|
||||
'views/mrp_workorder_views.xml',
|
||||
'views/purchase_order_view.xml',
|
||||
'views/stock_picking_view.xml',
|
||||
],
|
||||
'test': [
|
||||
],
|
||||
|
||||
@@ -150,5 +150,10 @@
|
||||
<field name="name">采购单已逾期提醒</field>
|
||||
<field name="model">purchase.order</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_quality_check" model="jikimo.message.bussiness.node">
|
||||
<field name="name">待质检提醒</field>
|
||||
<field name="model">product.product</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -389,5 +389,17 @@
|
||||
事项:[共有{{num}}个采购订单已逾期]({{url}})
|
||||
</field>
|
||||
</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>
|
||||
</odoo>
|
||||
@@ -13,3 +13,4 @@ from . import sf_message_maintenance_logs
|
||||
from . import sf_message_mrp_production_wizard
|
||||
from . import sf_message_mrp_production_adjust_wizard
|
||||
from . import sf_message_product
|
||||
from . import sf_message_quality_check
|
||||
|
||||
@@ -63,8 +63,9 @@ class SFMessageMrpProduction(models.Model):
|
||||
[('origin', 'in', mrp_production_names), ('state', '=', 'assigned')])
|
||||
if stock_picking_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
action_id = self.env.ref('sf_message.action_picking_outsourced_tree_ready').id
|
||||
menu_id = self.env.ref('stock.menu_stock_root').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}&menu_id={menu_id}"
|
||||
content = content.replace('{{name}}', mrp_production.product_id.name).replace('{{url}}',
|
||||
url_with_id).replace(
|
||||
'{{num}}', str(stock_picking_num))
|
||||
|
||||
@@ -3,7 +3,7 @@ from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessagePlan(models.Model):
|
||||
class SFMessageProduct(models.Model):
|
||||
_name = 'product.product'
|
||||
_inherit = ['product.product', 'jikimo.message.dispatch']
|
||||
|
||||
@@ -28,6 +28,18 @@ class SFMessagePlan(models.Model):
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
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
|
||||
|
||||
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([
|
||||
("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
|
||||
@@ -32,7 +32,7 @@ class SFMessageSale(models.Model):
|
||||
for purchase_order_id in purchase_order_ids:
|
||||
if purchase_order_id.purchase_type == 'outsourcing':
|
||||
purchase_order_id.add_queue('委外加工采购单提醒')
|
||||
if purchase_order_id.purchase_type == 'standard':
|
||||
if purchase_order_id.purchase_type == 'outside':
|
||||
purchase_order_id.add_queue('外购订单采购单提醒')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
|
||||
37
sf_message/views/stock_picking_view.xml
Normal file
37
sf_message/views/stock_picking_view.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_picking_internal_search_sf" model="ir.ui.view">
|
||||
<field name="name">stock.picking.search</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='activities_exception']" position="before">
|
||||
<filter name="outsourced" string="外协出库" domain="[('picking_type_id.name', '=', '外协出库')]"
|
||||
invisible="1"/>
|
||||
<separator/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_picking_outsourced_tree_ready" model="ir.actions.act_window">
|
||||
<field name="name">待办</field>
|
||||
<field name="res_model">stock.picking</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_mode">tree,kanban,form,calendar</field>
|
||||
<field name="domain"></field>
|
||||
<field name="context">{'search_default_outsourced': 1,'contact_display': 'partner_address',
|
||||
'search_default_available': 1}
|
||||
</field>
|
||||
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
没有仓库调拨。 让我们创建一个!
|
||||
</p>
|
||||
<p>
|
||||
移动允许您将产品从一个位置移动到另外一个位置。
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user