还原代码
This commit is contained in:
@@ -1005,14 +1005,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
def _compute_state(self):
|
||||
# super()._compute_state()
|
||||
for workorder in self:
|
||||
logging.info(workorder.name)
|
||||
logging.info(workorder.state)
|
||||
logging.info(workorder.sequence)
|
||||
logging.info(workorder.id)
|
||||
# logging.info(workorder.blocked_by_workorder_ids)
|
||||
# logging.info(workorder.blocked_by_workorder_ids.name)
|
||||
# logging.info(workorder.blocked_by_workorder_ids.sequence)
|
||||
logging.info('----------------------')
|
||||
if workorder.sequence != 1:
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
@@ -1308,9 +1300,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
if record.routing_type == '装夹预调':
|
||||
if not record.rfid_code and record.is_rework is False:
|
||||
raise UserError("请扫RFID码进行绑定")
|
||||
# if record.is_rework is False:
|
||||
# if not record.material_center_point:
|
||||
# raise UserError("坯料中心点为空,请检查")
|
||||
if record.is_rework is False:
|
||||
if not record.material_center_point:
|
||||
raise UserError("坯料中心点为空,请检查")
|
||||
# if record.X_deviation_angle <= 0:
|
||||
# raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
||||
record.process_state = '待加工'
|
||||
@@ -1344,8 +1336,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
if record.routing_type == '表面工艺':
|
||||
if record.picking_ids:
|
||||
picks = record.picking_ids.filtered(lambda p: p.state not in ('done'))
|
||||
# if picks:
|
||||
# raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||
if picks:
|
||||
raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||
tem_date_planned_finished = record.date_planned_finished
|
||||
tem_date_finished = record.date_finished
|
||||
logging.info('routing_type:%s' % record.routing_type)
|
||||
|
||||
@@ -294,10 +294,10 @@ class StockRule(models.Model):
|
||||
# 为同一个product_id创建一个生产订单名称列表
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
# production_programming = self.env['mrp.production'].search(
|
||||
# [('product_id.id', '=', production_item.product_id.id),
|
||||
# ('origin', '=', production_item.origin)],
|
||||
# limit=1, order='id asc')
|
||||
production_programming = self.env['mrp.production'].search(
|
||||
[('product_id.id', '=', production_item.product_id.id),
|
||||
('origin', '=', production_item.origin)],
|
||||
limit=1, order='id asc')
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
# 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
@@ -310,7 +310,6 @@ class StockRule(models.Model):
|
||||
'programming_state': '编程中'})
|
||||
if not technology_design_values:
|
||||
if production_item.product_id.categ_id.type == '成品':
|
||||
production_item.product_id.model_processing_panel = 'ZM,FM'
|
||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||
i = 0
|
||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||
|
||||
@@ -250,8 +250,8 @@
|
||||
<field name='tag_type' readonly="1" attrs='{"invisible": [("tag_type","=",False)]}'
|
||||
decoration-danger="tag_type == '重新加工'"/>
|
||||
<field name="is_test_env" invisible="1"/>
|
||||
<field name="rfid_code" force_save="1" readonly="0" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget='qrcode_widget'/>
|
||||
<field name="rfid_code" string="RFID码(手动输入框)" force_save="1" readonly="0" cache="True"
|
||||
attrs="{'invisible': ['|',('rfid_code_old', '!=', False), ('is_test_env', '=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
|
||||
@@ -28,27 +28,27 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
domain = [('programming_no', '=', ret['programming_no'])]
|
||||
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
||||
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
||||
else:
|
||||
domain += [('state', '=', 'confirmed')]
|
||||
productions = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search(domain)
|
||||
production_technology_comfirm = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search([('programming_no', '=', ret['programming_no']),('state','=','confirmed')])
|
||||
if productions:
|
||||
# 拉取所有加工面的程序文件
|
||||
# for r in ret['processing_panel'].split(','):
|
||||
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
# if os.path.exists(program_path_tmp_r):
|
||||
# files_r = os.listdir(program_path_tmp_r)
|
||||
# if files_r:
|
||||
# for file_name in files_r:
|
||||
# file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
# os.remove(file_path)
|
||||
# download_state = request.env['sf.cnc.processing'].with_user(
|
||||
# request.env.ref("base.user_admin")).download_file_tmp(
|
||||
# ret['folder_name'], r)
|
||||
# if download_state is False:
|
||||
# res['status'] = -2
|
||||
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
# return json.JSONEncoder().encode(res)
|
||||
for r in ret['processing_panel'].split(','):
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
if os.path.exists(program_path_tmp_r):
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
ret['folder_name'], r)
|
||||
if download_state is False:
|
||||
res['status'] = -2
|
||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
return json.JSONEncoder().encode(res)
|
||||
for production in productions:
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
@@ -65,30 +65,29 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
cnc_workorder_has.write(
|
||||
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
||||
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
||||
# for panel in ret['processing_panel'].split(','):
|
||||
# # 查询状态为进行中且工序类型为CNC加工的工单
|
||||
# cnc_workorder = productions.workorder_ids.filtered(
|
||||
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
|
||||
# 'cancel'] and ac.processing_panel == panel)
|
||||
# if cnc_workorder:
|
||||
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# # panel)
|
||||
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||
# files_panel = os.listdir(program_path_tmp_panel)
|
||||
# if files_panel:
|
||||
# for file in files_panel:
|
||||
# file_extension = os.path.splitext(file)[1]
|
||||
# if file_extension.lower() == '.pdf':
|
||||
# panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||
# logging.info('panel_file_path:%s' % panel_file_path)
|
||||
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
# pre_workorder = productions.workorder_ids.filtered(
|
||||
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||
# 'cancel'] and ap.processing_panel == panel)
|
||||
# if pre_workorder:
|
||||
# pre_workorder.write(
|
||||
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
cnc_workorder = productions.workorder_ids.filtered(
|
||||
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
|
||||
'cancel'] and ac.processing_panel == panel)
|
||||
if cnc_workorder:
|
||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# panel)
|
||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||
files_panel = os.listdir(program_path_tmp_panel)
|
||||
if files_panel:
|
||||
for file in files_panel:
|
||||
file_extension = os.path.splitext(file)[1]
|
||||
if file_extension.lower() == '.pdf':
|
||||
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||
logging.info('panel_file_path:%s' % panel_file_path)
|
||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
pre_workorder = productions.workorder_ids.filtered(
|
||||
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||
'cancel'] and ap.processing_panel == panel)
|
||||
if pre_workorder:
|
||||
pre_workorder.write(
|
||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
||||
res.update({
|
||||
|
||||
Reference in New Issue
Block a user