Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/tax_sync
This commit is contained in:
@@ -36,15 +36,13 @@ class MrpProduction(models.Model):
|
||||
def _compute_tool_state_remark(self):
|
||||
for item in self:
|
||||
if item.workorder_ids:
|
||||
work_ids = []
|
||||
for workorder_id in item.workorder_ids:
|
||||
if workorder_id.tool_state == '1':
|
||||
work_ids.append(workorder_id)
|
||||
if work_ids:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1')
|
||||
tool_state_remark = ''
|
||||
for work_id in work_ids:
|
||||
if tool_state_remark == '':
|
||||
tool_state_remark = f"{work_id.tool_state_remark}"
|
||||
tool_state_remark = f'{work_id.tool_state_remark}'
|
||||
else:
|
||||
tool_state_remark = f"{tool_state_remark}\n{work_id.tool_state_remark}"
|
||||
item.tool_state_remark = tool_state_remark
|
||||
@@ -56,16 +54,10 @@ class MrpProduction(models.Model):
|
||||
for item in self:
|
||||
if item.workorder_ids:
|
||||
tool_state = item.tool_state
|
||||
work_ids_1 = []
|
||||
work_ids_2 = []
|
||||
for workorder_id in item.workorder_ids:
|
||||
if workorder_id.tool_state == '2':
|
||||
work_ids_2.append(workorder_id)
|
||||
elif workorder_id.tool_state == '1':
|
||||
work_ids_1.append(workorder_id)
|
||||
if work_ids_2:
|
||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
|
||||
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
elif work_ids_1:
|
||||
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
item.tool_state = '1'
|
||||
else:
|
||||
item.tool_state = '0'
|
||||
@@ -695,6 +687,9 @@ class MrpProduction(models.Model):
|
||||
for work_id in work_ids:
|
||||
if panel_sequence_list.get(work_id.name):
|
||||
work_id.sequence = panel_sequence_list[work_id.name]
|
||||
if rec.tool_state in ['1', '2']:
|
||||
rec.workorder_ids.filtered(
|
||||
lambda a: a.routing_type == '装夹预调' and a.state in 'ready').compute_state()
|
||||
|
||||
# 创建工单并进行排序
|
||||
def _create_workorder(self, item):
|
||||
|
||||
@@ -910,39 +910,49 @@ class ResMrpWorkOrder(models.Model):
|
||||
# if workorder.state not in ['cancel', 'rework']:
|
||||
# workorder.state = 'rework'
|
||||
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
||||
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
||||
if workorder.production_id.tool_state in ['1', '2']:
|
||||
if workorder.state in ['ready']:
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
elif workorder.state in ['waiting']:
|
||||
continue
|
||||
elif workorder.state == 'pending' and workorder == self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('routing_type', '=', '装夹预调'),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence"):
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
elif workorder.production_id.tool_state in ['0']:
|
||||
if workorder.production_id.workorder_ids.filtered(lambda a: a.state == 'rework'):
|
||||
if not workorder.production_id.workorder_ids.filtered(
|
||||
lambda a: (a.routing_type not in ['装夹预调'] and
|
||||
a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
||||
# 查询工序最小的非完工、非返工的装夹预调工单
|
||||
work_id = self.search(
|
||||
workorder_ids = workorder.production_id.workorder_ids
|
||||
work_bo = True
|
||||
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
||||
if not workorder_ids.filtered(
|
||||
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
||||
and a.processing_panel == wo.processing_panel)):
|
||||
work_bo = False
|
||||
break
|
||||
if (workorder.production_id.programming_state == '已编程' and work_bo
|
||||
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
||||
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
||||
if workorder.production_id.tool_state in ['1', '2']:
|
||||
if workorder.state in ['ready']:
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
elif workorder.state in ['waiting']:
|
||||
continue
|
||||
elif workorder.state == 'pending' and workorder == self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('routing_type', '=', '装夹预调'),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence")
|
||||
if workorder == work_id:
|
||||
if workorder.production_id.reservation_state == 'assigned':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.production_id.reservation_state != 'assigned':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
order="sequence"):
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
elif workorder.production_id.tool_state in ['0']:
|
||||
if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
||||
if not workorder_ids.filtered(
|
||||
lambda a: (a.routing_type not in ['装夹预调'] and
|
||||
a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
||||
# 查询工序最小的非完工、非返工的装夹预调工单
|
||||
work_id = self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('routing_type', '=', '装夹预调'),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence")
|
||||
if workorder == work_id:
|
||||
if workorder.production_id.reservation_state == 'assigned':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.production_id.reservation_state != 'assigned':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
|
||||
logging.info('工序:%s' % workorder.sequence)
|
||||
logging.info('工单最终状态:%s' % workorder.state)
|
||||
@@ -978,6 +988,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||
# workorder.state = 'waiting'
|
||||
|
||||
def compute_state(self):
|
||||
self._compute_state()
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
if self.routing_type == '装夹预调':
|
||||
@@ -1195,38 +1208,27 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
# 将FTP的检测报告文件下载到临时目录
|
||||
def download_reportfile_tmp(self, workorder, reportpath):
|
||||
logging.info('reportpath:%s' % reportpath)
|
||||
production_no_ftp = reportpath.split('/')
|
||||
production_no = workorder.production_id.name.replace('/', '_')
|
||||
# ftp地址
|
||||
remotepath = os.path.join('/NC', production_no_ftp[1], 'detection')
|
||||
logging.info('ftp地址:%s' % remotepath)
|
||||
if reportpath.find(production_no) != -1:
|
||||
# 服务器内临时地址
|
||||
serverdir = os.path.join('/tmp', production_no_ftp[1], 'detection')
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
|
||||
ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
|
||||
logging.info('download_state:%s' % download_state)
|
||||
else:
|
||||
download_state = 2
|
||||
logging.info('reportpath/ftp地址:%s' % reportpath)
|
||||
logging.info('processing_panel:%s' % workorder.processing_panel)
|
||||
serverdir = os.path.join('/tmp', workorder.production_id.name.replace('/', '_'), 'detection',
|
||||
workorder.processing_panel)
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
|
||||
ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
if not ftp.file_exists_1(reportpath):
|
||||
logging.info('文件不存在:%s' % reportpath)
|
||||
download_state = ftp.download_program_file(reportpath, serverdir)
|
||||
logging.info('download_state:%s' % download_state)
|
||||
return download_state
|
||||
|
||||
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
|
||||
def get_detection_file(self, workorder, reportPath):
|
||||
# if reportPath.startswith('/'):
|
||||
# reportPath = reportPath[4:]
|
||||
# serverdir = os.path.join('/tmp', reportPath)
|
||||
serverdir = '/tmp' + reportPath
|
||||
serverdir = os.path.join('/tmp', workorder.production_id.name.replace('/', '_'), 'detection',
|
||||
workorder.processing_panel)
|
||||
logging.info('get_detection_file-serverdir:%s' % serverdir)
|
||||
serverdir_prefix = os.path.dirname(serverdir)
|
||||
logging.info('serverdir_prefix-serverdir:%s' % serverdir_prefix)
|
||||
for root, dirs, files in os.walk(serverdir_prefix):
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
for filename in files:
|
||||
logging.info('filename:%s' % filename)
|
||||
logging.info('reportPath:%s' % os.path.basename(reportPath))
|
||||
if filename == os.path.basename(reportPath):
|
||||
report_file_path = os.path.join(root, filename)
|
||||
logging.info('get_detection_file-report_file_path:%s' % report_file_path)
|
||||
|
||||
Reference in New Issue
Block a user