制造订单合并一张编程单下发时,工件配送记录的未下发nc程序为未下发及cnc程序没有对应ftp文件路径问题
This commit is contained in:
@@ -335,10 +335,10 @@ class MrpProduction(models.Model):
|
|||||||
production_programming = self.search(
|
production_programming = self.search(
|
||||||
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
||||||
limit=1, order='id asc')
|
limit=1, order='id asc')
|
||||||
if not production_programming.programming_no:
|
if not production_programming.programming_no or (is_fetchcnc is True and scrap_production):
|
||||||
# 制造订单报废/返工也需重新编程
|
# 制造订单报废/返工也需重新编程
|
||||||
if (is_fetchcnc is True and scrap_production) or (
|
if (is_fetchcnc is True and scrap_production) or (
|
||||||
is_fetchcnc is False and not scrap_production):
|
is_fetchcnc is False and scrap_production):
|
||||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
|
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
|
||||||
scrap_production)
|
scrap_production)
|
||||||
else:
|
else:
|
||||||
@@ -408,6 +408,12 @@ class MrpProduction(models.Model):
|
|||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
|
if is_fetchcnc is False and scrap_production:
|
||||||
|
production.write({'programming_no': scrap_production.programming_no,
|
||||||
|
'programming_state': '已编程'})
|
||||||
|
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
|
||||||
|
'cnc_ids': scrap_production.workorder_ids.filtered(
|
||||||
|
lambda t1: t1.routing_type == 'CNC加工').cnc_ids})
|
||||||
for workorder in production.workorder_ids:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
|
|||||||
@@ -766,6 +766,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', productions.origin)])
|
sale_order = self.env['sale.order'].sudo().search([('name', '=', productions.origin)])
|
||||||
if sale_order:
|
if sale_order:
|
||||||
|
sale_order.mrp_production_ids |= productions
|
||||||
# sale_order.write({'schedule_status': 'to schedule'})
|
# sale_order.write({'schedule_status': 'to schedule'})
|
||||||
self.env['sf.production.plan'].sudo().with_company(self.production_id.company_id).create({
|
self.env['sf.production.plan'].sudo().with_company(self.production_id.company_id).create({
|
||||||
'name': productions.name,
|
'name': productions.name,
|
||||||
@@ -995,7 +996,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'date_planned_finished': tem_date_planned_finished # 保持原值
|
'date_planned_finished': tem_date_planned_finished # 保持原值
|
||||||
})
|
})
|
||||||
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
|
||||||
record.production_id.write({'state': 'cancel'})
|
record.production_id.action_cancel()
|
||||||
record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
|
record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
|
||||||
if record.is_remanufacture is True:
|
if record.is_remanufacture is True:
|
||||||
record.recreateManufacturingOrWorkerOrder()
|
record.recreateManufacturingOrWorkerOrder()
|
||||||
@@ -1130,6 +1131,8 @@ class CNCprocessing(models.Model):
|
|||||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
||||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||||
'estimated_processing_time': obj['estimated_processing_time'],
|
'estimated_processing_time': obj['estimated_processing_time'],
|
||||||
|
'program_path': obj['program_path'],
|
||||||
|
'cnc_id': obj['cnc_id'].id,
|
||||||
'remark': obj['remark']
|
'remark': obj['remark']
|
||||||
})
|
})
|
||||||
return cnc_processing_str
|
return cnc_processing_str
|
||||||
@@ -1137,12 +1140,20 @@ class CNCprocessing(models.Model):
|
|||||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||||
logging.info('serverdir:%s' % serverdir)
|
logging.info('serverdir:%s' % serverdir)
|
||||||
|
logging.info('cnc_processing:%s' % cnc_processing)
|
||||||
for root, dirs, files in os.walk(serverdir):
|
for root, dirs, files in os.walk(serverdir):
|
||||||
for f in files:
|
for f in files:
|
||||||
|
logging.info('splitext(f):%s' % os.path.splitext(f)[1])
|
||||||
if os.path.splitext(f)[1] == ".pdf":
|
if os.path.splitext(f)[1] == ".pdf":
|
||||||
full_path = os.path.join(serverdir, root, f)
|
full_path = os.path.join(serverdir, root, f)
|
||||||
if full_path is not False:
|
logging.info('full_path:%s' % full_path)
|
||||||
|
logging.info('routing_type:%s' % cnc_processing.workorder_id.routing_type)
|
||||||
|
logging.info('cnc_worksheet:%s' % cnc_processing.workorder_id.cnc_worksheet)
|
||||||
|
# with open(full_path, 'rb') as pdf_file:
|
||||||
|
# file_content = pdf_file.read()
|
||||||
|
# cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(file_content)
|
||||||
if not cnc_processing.workorder_id.cnc_worksheet:
|
if not cnc_processing.workorder_id.cnc_worksheet:
|
||||||
|
logging.info('full_path111555:%s' % full_path)
|
||||||
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
cnc_processing.workorder_id.cnc_worksheet = base64.b64encode(
|
||||||
open(full_path, 'rb').read())
|
open(full_path, 'rb').read())
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -631,8 +631,8 @@ class ReStockMove(models.Model):
|
|||||||
'reserved_uom_qty': 1.0,
|
'reserved_uom_qty': 1.0,
|
||||||
'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
|
'lot_id': purchase.picking_ids.move_line_ids.lot_id.id,
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
# 'workorder_id': '' if not sorted_workorders else sorted_workorders.id,
|
||||||
'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
# 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,
|
||||||
'state': 'assigned',
|
'state': 'assigned',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,12 +63,16 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
logging.info('cnc_processing111:%s' % cnc_processing)
|
logging.info('cnc_processing111:%s' % cnc_processing)
|
||||||
if cnc_processing:
|
if cnc_processing:
|
||||||
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
||||||
if cnc_program and cnc_processing_arr:
|
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
||||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||||
|
if cnc_program and cnc_processing_arr:
|
||||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||||
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
|
cnc_program |= cnc_production
|
||||||
|
if not cnc_program and cnc_processing_arr:
|
||||||
|
cnc_program = cnc_production
|
||||||
cnc_program_ids = [item.id for item in cnc_program]
|
cnc_program_ids = [item.id for item in cnc_program]
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
[('production_id', 'in', cnc_program_ids)])
|
[('production_id', 'in', cnc_program_ids)])
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class FtpController():
|
|||||||
os.makedirs(serverdir)
|
os.makedirs(serverdir)
|
||||||
try:
|
try:
|
||||||
logging.info("进入FTP目录 ")
|
logging.info("进入FTP目录 ")
|
||||||
|
self.ftp.pwd()
|
||||||
|
logging.info('当前目录:%s' % self.ftp.pwd())
|
||||||
logging.info('目录:%s' % target_dir)
|
logging.info('目录:%s' % target_dir)
|
||||||
target_dir1 = target_dir.split('/')
|
target_dir1 = target_dir.split('/')
|
||||||
logging.info('目录1:%s' % target_dir1[1])
|
logging.info('目录1:%s' % target_dir1[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user