Merge branch 'feature/CNC功能刀具用刀校验' into feature/销售订单、工单优化

This commit is contained in:
yuxianghui
2024-07-16 10:41:56 +08:00
8 changed files with 221 additions and 107 deletions

View File

@@ -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
from odoo.exceptions import UserError,ValidationError
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
@@ -158,6 +158,21 @@ class ResMrpWorkOrder(models.Model):
# 加工图纸
processing_drawing = fields.Binary(string='加工图纸')
# 功能刀具状态
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
store=True, compute='_compute_tool_state')
@api.depends('cnc_ids.tool_state')
def _compute_tool_state(self):
for item in self:
if item:
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
item.tool_state = '2'
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
item.tool_state = '1'
else:
item.tool_state = '0'
@api.depends('production_id')
def _compute_save_name(self):
"""
@@ -1004,13 +1019,15 @@ class ResMrpWorkOrder(models.Model):
if workorder.state != 'done':
is_production_id = False
if record.routing_type == '解除装夹':
for workorder in record.production_id.workorder_ids:
if workorder.processing_panel == record.processing_panel:
rfid_code = workorder.rfid_code
workorder.write({'rfid_code_old': rfid_code,
'rfid_code': False})
workorder.rfid_code_old = rfid_code
workorder.rfid_code = False
for workorder in record.production_id.workorder_ids.filtered(
lambda a: a.processing_panel == record.processing_panel):
rfid_code = workorder.rfid_code
workorder.write({'rfid_code_old': rfid_code,
'rfid_code': False})
if workorder.rfid_code:
raise ValidationError(f'{workorder.name}】工单解绑失败,请重新点击完成按钮!!!')
workorder.rfid_code_old = rfid_code
workorder.rfid_code = False
if is_production_id is True and record.routing_type in ['解除装夹', '表面工艺']:
logging.info('product_qty:%s' % record.production_id.product_qty)
for move_raw_id in record.production_id.move_raw_ids:
@@ -1130,6 +1147,8 @@ class CNCprocessing(models.Model):
program_path = fields.Char('程序文件路径')
program_create_date = fields.Datetime('程序创建日期')
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='刀具状态', default='0')
# mrs下发编程单创建CNC加工
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
cnc_processing = None