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