Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -381,6 +381,10 @@ class MrpProduction(models.Model):
|
||||
# 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工
|
||||
if production.tool_state == '2':
|
||||
production.state = 'rework'
|
||||
if all(wo_state in ('done', 'rework', 'cancel') for wo_state in production.workorder_ids.mapped('state')):
|
||||
if production.state not in ['scrap', 'rework']:
|
||||
production.state = 'done'
|
||||
|
||||
|
||||
# 退回调整
|
||||
def technology_back_adjust(self):
|
||||
|
||||
@@ -672,8 +672,8 @@ class StockPicking(models.Model):
|
||||
'partner_id': self.partner_id.id,
|
||||
})
|
||||
move_dest_id = False
|
||||
# 如果当前工单是是制造订单的最后一个工单
|
||||
if workorder == item.workorder_ids[-1]:
|
||||
# 如果当前工单是是制造订单的最后一个工艺外协工单
|
||||
if workorder == next((workorder for workorder in reversed(item.workorder_ids) if workorder.is_subcontract), None):
|
||||
move_dest_id = item.move_raw_ids[0].id
|
||||
else:
|
||||
# 从sorted_workorders中找到上一工单的move
|
||||
|
||||
@@ -131,11 +131,6 @@
|
||||
<field name="deadline_of_delivery" readonly="1"/>
|
||||
<field name="tool_state_remark2" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
|
||||
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', True)]}"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="(//header//button[@name='button_mark_done'])[1]" position="replace">
|
||||
<button name="button_mark_done"
|
||||
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '!=', [])]}"
|
||||
@@ -260,13 +255,6 @@
|
||||
type="object" groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
<button name="action_cancel" type="object" string="Cancel" data-hotkey="z"
|
||||
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', False)]}"
|
||||
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process ?"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//header//button[@name='button_unbuild']" position="replace">
|
||||
<button name="button_unbuild" type="object" string="拆单"
|
||||
attrs="{'invisible': [('state', '!=', 'done')]}" data-hotkey="shift+v"
|
||||
@@ -310,12 +298,14 @@
|
||||
type="object" groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
<xpath expr="//header//button[@name='action_cancel'][2]" position="replace">
|
||||
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
|
||||
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', False)]}"
|
||||
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'rework', 'cancel')), ('confirm_cancel', '=', False)]}"
|
||||
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process ?"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel'][1]" position="replace"></xpath>
|
||||
|
||||
<xpath expr="//header//button[@name='button_unbuild']" position="replace">
|
||||
<button name="button_unbuild" type="object" string="拆单"
|
||||
attrs="{'invisible': [('state', '!=', 'done')]}" data-hotkey="shift+v"
|
||||
|
||||
@@ -287,6 +287,8 @@ class ReworkWizard(models.TransientModel):
|
||||
self.production_id.update_programming_state()
|
||||
self.production_id.write(
|
||||
{'programming_state': '编程中', 'work_state': '编程中', 'state': 'progress'})
|
||||
# ================= 返工完成,制造订单状态置为加工中 ==============
|
||||
self.production_id.write({'state': 'progress', 'is_rework': False})
|
||||
|
||||
@api.onchange('production_id')
|
||||
def onchange_processing_panel_id(self):
|
||||
|
||||
@@ -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'],
|
||||
'sf_manufacturing','product'],
|
||||
'data': [
|
||||
'data/bussiness_node.xml',
|
||||
'data/cron_data.xml',
|
||||
|
||||
@@ -39,12 +39,6 @@ class MessageSfMrsConnect(Sf_Mrs_Connect):
|
||||
_logger.info('无效用刀异常消息推送接口:%s' % ret)
|
||||
except Exception as e:
|
||||
_logger.info('无效用刀异常消息推送接口:%s' % e)
|
||||
|
||||
try:
|
||||
productions = request.env['mrp.production'].sudo().search([('id', '=', res.get('production_ids')[0])])
|
||||
productions.add_queue('工单已下发通知')
|
||||
except Exception as e:
|
||||
_logger.info('工单已下发通知异常:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/api/maintenance_logs/notify', type='json', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<!--工单-->
|
||||
<record id="bussiness_mrp_workorder_remind" model="jikimo.message.bussiness.node">
|
||||
<field name="name">工单已下发通知</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="model">product.product</field>
|
||||
</record>
|
||||
<!--发货调拨-->
|
||||
<record id="production_completed_warehouse_reminder" model="jikimo.message.bussiness.node">
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
|
||||
<record id="template_mrp_workorder_remind" model="jikimo.message.template">
|
||||
<field name="name">工单已下发通知</field>
|
||||
<field name="model_id" ref="mrp.model_mrp_production"/>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="model_id" ref="product.model_product_product"/>
|
||||
<field name="model">product.product</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_remind"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
|
||||
@@ -12,3 +12,4 @@ from . import sf_message_quality_cnc_test
|
||||
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
|
||||
|
||||
@@ -69,25 +69,16 @@ class SFMessageMrpProduction(models.Model):
|
||||
url_with_id).replace(
|
||||
'{{num}}', str(stock_picking_num))
|
||||
contents.append(content)
|
||||
if message_queue_id.message_template_id.name == '工单已下发通知':
|
||||
content = message_queue_id.message_template_id.content
|
||||
mrp_production = self.env['mrp.production'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||
production_num = self.env['mrp.production'].sudo().search_count(
|
||||
[('product_id', '=', mrp_production.product_id.id)])
|
||||
if production_num >= 1:
|
||||
url = self.get_request_url()
|
||||
content = content.replace('{{product_id}}', mrp_production.product_id.name).replace(
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
if unique_products:
|
||||
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
|
||||
unique_products_contents = self.get_production_info(content, unique_products, 'confirmed',
|
||||
'sf_plan.sf_production_plan_action1')
|
||||
action_id)
|
||||
contents.extend(unique_products_contents)
|
||||
if technology_to_confirmed:
|
||||
action_id = self.env.ref('mrp.mrp_production_action').id
|
||||
technology_to_confirmed_contents = self.get_production_info(content, technology_to_confirmed,
|
||||
'technology_to_confirmed',
|
||||
'mrp.mrp_production_action')
|
||||
action_id)
|
||||
contents.extend(technology_to_confirmed_contents)
|
||||
logging.info('生产完工入库提醒: %s' % contents)
|
||||
return contents
|
||||
@@ -100,7 +91,6 @@ class SFMessageMrpProduction(models.Model):
|
||||
[('product_id', '=', products_id), ('state', '=', state)])
|
||||
if production_num >= 1:
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref(action_id).id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
new_content = (content.replace('{{name}}', product_name)
|
||||
.replace('{{url}}', url_with_id)
|
||||
@@ -120,17 +110,3 @@ class SFMessageMrpProduction(models.Model):
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def get_request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
@@ -11,7 +11,7 @@ class SFMessageMrpProductionWizard(models.TransientModel):
|
||||
productions = super(SFMessageMrpProductionWizard, self).confirm()
|
||||
try:
|
||||
for production_info in self.production_id:
|
||||
if production_info.state == 'confirmed':
|
||||
if production_info.state == 'confirmed' and production_info.product_id.categ_id.type == '成品':
|
||||
production_info.add_queue('待排程')
|
||||
for production_id in productions:
|
||||
workorder_ids = production_id.workorder_ids.filtered(
|
||||
|
||||
38
sf_message/models/sf_message_product.py
Normal file
38
sf_message/models/sf_message_product.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessagePlan(models.Model):
|
||||
_name = 'product.product'
|
||||
_inherit = ['product.product', '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
|
||||
product_product = self.env['product.product'].sudo().search([('id', '=', int(message_queue_id.res_id))])
|
||||
production_num = self.env['mrp.production'].sudo().search_count(
|
||||
[('product_id', '=', product_product.id)])
|
||||
if production_num >= 1:
|
||||
url = self.get_request_url()
|
||||
content = content.replace('{{product_id}}', product_product.name).replace(
|
||||
'{{number}}', str(production_num)).replace(
|
||||
'{{request_url}}', url)
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def get_request_url(self):
|
||||
url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
active_id = self.env['mrp.workcenter'].sudo().search([('name', '=', '工件装夹中心')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
@@ -25,7 +25,8 @@ class SFMessageStockPicking(models.Model):
|
||||
super(SFMessageStockPicking, self)._compute_state()
|
||||
try:
|
||||
for record in self:
|
||||
if record.state == 'assigned' and record.picking_type_id.sequence_code == 'PC':
|
||||
if (record.state == 'assigned' and record.picking_type_id.sequence_code == 'PC'
|
||||
and record.product_id.categ_id.type == '坯料'):
|
||||
record.add_queue('坯料发料提醒')
|
||||
|
||||
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
|
||||
|
||||
@@ -17,4 +17,5 @@ class SfMessageTemplate(models.Model):
|
||||
res.append('sf.maintenance.logs')
|
||||
res.append('quality.cnc.test')
|
||||
res.append('mrp.production')
|
||||
res.append('product.product')
|
||||
return res
|
||||
|
||||
@@ -12,6 +12,23 @@ class SFMessageWork(models.Model):
|
||||
_name = 'mrp.workorder'
|
||||
_inherit = ['mrp.workorder', 'jikimo.message.dispatch']
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||
'production_id.programming_state')
|
||||
def _compute_state(self):
|
||||
super(SFMessageWork, self)._compute_state()
|
||||
for workorder in self:
|
||||
work_ids = workorder.production_id.workorder_ids.filtered(lambda w: w.routing_type == '装夹预调')
|
||||
if work_ids:
|
||||
min_sequence_wk = work_ids.sorted(key=lambda w: w.sequence)[0]
|
||||
if workorder.state == 'ready' and workorder.routing_type == '装夹预调' and workorder.id == min_sequence_wk.id:
|
||||
message_template = self.env["jikimo.message.template"].sudo().search([("name", "=", '工单已下发通知')], limit=1)
|
||||
jikimo_message_queue = self.env['jikimo.message.queue'].sudo().search(
|
||||
[('res_id', '=', workorder.production_id.product_id.id), ("message_status", "in", ("pending", "sent")),
|
||||
('message_template_id', '=', message_template.id)])
|
||||
if not jikimo_message_queue:
|
||||
workorder.production_id.product_id.add_queue('工单已下发通知')
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
bussiness_node = None
|
||||
|
||||
Reference in New Issue
Block a user