添加工单开始校验
This commit is contained in:
@@ -35,7 +35,7 @@ class MrpProduction(models.Model):
|
||||
@api.depends('workorder_ids.tool_state')
|
||||
def _compute_tool_state(self):
|
||||
for item in self:
|
||||
if item:
|
||||
if item.workorder_ids:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
|
||||
@@ -13,7 +13,7 @@ from dateutil.relativedelta import relativedelta
|
||||
# import subprocess
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo.exceptions import UserError,ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
||||
|
||||
|
||||
@@ -813,6 +813,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
# workorder.state = 'waiting'
|
||||
# if workorder.routing_type == 'CNC加工' and workorder.state == 'progress':
|
||||
# workorder.state = 'to be detected'
|
||||
|
||||
# for workorder in self:
|
||||
# if workorder.is_rework is True and workorder.state == 'done':
|
||||
# cnc_work = self.env['mrp.workorder'].search([('routing_type','=','CNC加工'),('production_id','=',workorder.production_id.id)])
|
||||
@@ -851,12 +852,10 @@ class ResMrpWorkOrder(models.Model):
|
||||
limit=1, order='id asc')
|
||||
if not cnc_workorder.cnc_ids:
|
||||
raise UserError(_('该制造订单还未下发CNC程序,请稍后再试'))
|
||||
# else:
|
||||
# for item in cnc_workorder.cnc_ids:
|
||||
# functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search(
|
||||
# [('tool_name_id.name', '=', item.cutting_tool_name)])
|
||||
# if not functional_cutting_tool:
|
||||
# raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
|
||||
else:
|
||||
if self.production_id.tool_state in ['1', '2']:
|
||||
raise UserError(
|
||||
f'制造订单【{self.production_id.name}】功能刀具状态为【{self.production_id.tool_state}】!')
|
||||
if self.routing_type == '解除装夹':
|
||||
'''
|
||||
记录开始时间
|
||||
|
||||
@@ -84,15 +84,15 @@ class CNCprocessing(models.Model):
|
||||
if production_id:
|
||||
data1 = datas['无效刀'].get(production_id.name) # data1: {'加工面1': [], ...}
|
||||
data2 = datas['缺刀'].get(production_id.name) # data2: {'加工面1': [], ...}
|
||||
tool_state_remark1 = ''
|
||||
# tool_state_remark1 = ''
|
||||
tool_state_remark2 = ''
|
||||
# 对无效刀信息进行处理
|
||||
for key in data1:
|
||||
if data1.get(key):
|
||||
if tool_state_remark1 != '':
|
||||
tool_state_remark1 = f'{tool_state_remark1}\n{key}无效刀:{data1.get(key)}'
|
||||
else:
|
||||
tool_state_remark1 = f'{key}无效刀:{data1.get(key)}'
|
||||
# if tool_state_remark1 != '':
|
||||
# tool_state_remark1 = f'{tool_state_remark1}\n{key}无效刀:{data1.get(key)}'
|
||||
# else:
|
||||
# tool_state_remark1 = f'{key}无效刀:{data1.get(key)}'
|
||||
# 无效刀处理逻辑
|
||||
# 1、创建制造订单无效刀检测结果记录
|
||||
logging.info('创建制造订单无效刀检测结果记录!')
|
||||
@@ -105,30 +105,19 @@ class CNCprocessing(models.Model):
|
||||
'test_results': '返工',
|
||||
'handle_result': '待处理'
|
||||
})
|
||||
# 2、将制造订单状态改为返工
|
||||
# production_id.write({
|
||||
# 'state': 'rework'
|
||||
# })
|
||||
# 对缺刀信息进行处理
|
||||
if tool_state_remark1 == '':
|
||||
for key in data2:
|
||||
if data2.get(key) and not data1.get(key):
|
||||
if tool_state_remark2 != '':
|
||||
tool_state_remark2 = f'{tool_state_remark2}\n{key}缺刀:{data2.get(key)}'
|
||||
else:
|
||||
tool_state_remark2 = f'{key}缺刀:{data2.get(key)}'
|
||||
for key in data2:
|
||||
if data2.get(key):
|
||||
if tool_state_remark2 != '':
|
||||
tool_state_remark2 = f'{tool_state_remark2}\n{key}缺刀:{data2.get(key)}'
|
||||
else:
|
||||
tool_state_remark2 = f'{key}缺刀:{data2.get(key)}'
|
||||
# 将备注信息存入制造订单功能刀具状态的备注字段
|
||||
logging.info('修改制造订单功能刀具状态的备注字段')
|
||||
if production_id.tool_state_remark2 == '':
|
||||
production_id.write({
|
||||
'tool_state_remark': tool_state_remark2,
|
||||
'tool_state_remark2': tool_state_remark1
|
||||
})
|
||||
else:
|
||||
production_id.write({
|
||||
'tool_state_remark': tool_state_remark2,
|
||||
'tool_state_remark2': f'{production_id.tool_state_remark1}\n{tool_state_remark1}'
|
||||
})
|
||||
production_id.write({
|
||||
'tool_state_remark': tool_state_remark2,
|
||||
# 'tool_state_remark2': tool_state_remark1
|
||||
})
|
||||
logging.info('工单cnc程序用刀校验已完成!')
|
||||
|
||||
@api.model_create_multi
|
||||
|
||||
Reference in New Issue
Block a user