修复返工(CNC加工)

This commit is contained in:
jinling.yang
2024-07-23 10:33:22 +08:00
parent 83396f5434
commit ded1789813
7 changed files with 28 additions and 30 deletions

View File

@@ -242,7 +242,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('button_Work_End error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def PartQualityInspect(self, **kw):
"""

View File

@@ -763,11 +763,7 @@ class MrpProduction(models.Model):
'default_production_id': self.id,
'default_reprogramming_num': cloud_programming['reprogramming_num'],
'default_programming_state': cloud_programming['programming_state'],
'default_is_reprogramming': False if (cloud_programming['programming_state'] in ['编程中',
'待编程'] and self.programming_state in [
'编程中', '已编程'])
or (cloud_programming['programming_state'] in [
'已编程'] and self.programming_state in ['已编程未下发']) else True
'default_is_reprogramming': False if cloud_programming['programming_state'] not in ['已下发'] else True
}
}
@@ -802,7 +798,7 @@ class MrpProduction(models.Model):
'pending'] and m1.processing_panel == rework_item.processing_panel and m1.routing_type == 'CNC加工')
if not pending_workorder.cnc_ids:
production.get_new_program(rework_item.processing_panel)
production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
# production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
productions_not_delivered.write({'programming_state': '已编程', 'is_rework': False})
# 从cloud获取重新编程过的最新程序
@@ -817,17 +813,17 @@ class MrpProduction(models.Model):
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
# program_path_tmp_panel = os.path.join('/tmp', result['folder_name'], 'return', processing_panel)
# if os.path.exists(program_path_tmp_panel):
# files_r = os.listdir(program_path_tmp_panel)
# if files_r:
# for file_name in files_r:
# file_path = os.path.join(program_path_tmp_panel, file_name)
# os.remove(file_path)
# download_state = self.env['sf.cnc.processing'].download_file_tmp(result['folder_name'],
# processing_panel)
# if download_state is False:
# raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no))
program_path_tmp_panel = os.path.join('/tmp', result['folder_name'], 'return', processing_panel)
if os.path.exists(program_path_tmp_panel):
files_r = os.listdir(program_path_tmp_panel)
if files_r:
for file_name in files_r:
file_path = os.path.join(program_path_tmp_panel, file_name)
os.remove(file_path)
download_state = self.env['sf.cnc.processing'].download_file_tmp(result['folder_name'],
processing_panel)
if download_state is False:
raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no))
productions = self.env['mrp.production'].search(
[('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))])
if productions:
@@ -841,8 +837,8 @@ class MrpProduction(models.Model):
panel_workorder.cnc_ids.sudo().unlink()
self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
productions)
program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
processing_panel)
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# processing_panel)
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
files_panel = os.listdir(program_path_tmp_panel)
if files_panel:

View File

@@ -729,11 +729,12 @@ class ResMrpWorkOrder(models.Model):
cnc_workorder = self.env['mrp.workorder'].search(
[('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel),
('routing_type', '=', 'CNC加工'), ('state', '=', 'done'),
('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
('test_results', '=', '返工')])
if workorder.state not in ['cancel', 'progress', 'rework']:
if workorder.production_id.state == 'rework':
logging.info('len(re_work):%s' % len(re_work))
logging.info('len(cnc_workorder):%s' % len(cnc_workorder))
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
logging.info('is_rework:%s' % workorder.is_rework)
@@ -771,6 +772,7 @@ class ResMrpWorkOrder(models.Model):
# workorder.state = 'waiting'
elif workorder.production_id.state == 'progress':
logging.info('len(re_work):%s' % len(re_work))
logging.info('len(cnc_workorder):%s' % len(cnc_workorder))
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
logging.info('is_rework:%s' % workorder.is_rework)

View File

@@ -7,8 +7,8 @@ import os
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model):

View File

@@ -20,13 +20,13 @@
style='color:red;'/>次,且当前编程状态为
<field name="programming_state" string=""
decoration-info="programming_state == '待编程'"
decoration-success="programming_state == '已编程'"
decoration-success="programming_state == '已下发'"
decoration-warning="programming_state =='编程中'"
decoration-danger="programming_state =='已编程未下发'" readonly="1"/>
decoration-danger="programming_state =='已编程'" readonly="1"/>
</div>
<group>
<field name="is_reprogramming"
attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("programming_state","in",["编程中","已编程未下发"])]}'/>
attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("is_reprogramming","=",False)]}'/>
<field name="rework_reason"
attrs='{"invisible": [("routing_type","not in",["装夹预调","CNC加工"])],"required": [("routing_type","in",["装夹预调"])]}'/>
<field name="detailed_reason"

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests
from odoo import http
from odoo.http import request
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError

View File

@@ -6,8 +6,8 @@ import os
from datetime import datetime
from stl import mesh
# from OCC.Core.GProp import GProp_GProps
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api
from odoo.modules import get_resource_path