Accept Merge Request #1740: (feature/制造功能优化 -> develop)
Merge Request: 调整写入编程记录的位置 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1740?initial=true
This commit is contained in:
@@ -372,7 +372,8 @@ class MrpProduction(models.Model):
|
||||
if any(dr.test_results == '报废' and dr.handle_result == '已处理' for dr in
|
||||
production.detection_result_ids):
|
||||
production.state = 'cancel'
|
||||
if production.workorder_ids and all(wo_state in ('done', 'rework', 'cancel') for wo_state in production.workorder_ids.mapped('state')):
|
||||
if production.workorder_ids and all(
|
||||
wo_state in ('done', 'rework', 'cancel') for wo_state in production.workorder_ids.mapped('state')):
|
||||
if production.state not in ['scrap', 'rework', 'cancel']:
|
||||
production.state = 'done'
|
||||
|
||||
@@ -442,6 +443,10 @@ class MrpProduction(models.Model):
|
||||
for deleted_design in deleted_designs:
|
||||
workorder = self.env['mrp.workorder'].search([('technology_design_id', '=', deleted_design.id)])
|
||||
purchase = workorder._get_surface_technics_purchase_ids()
|
||||
account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)])
|
||||
if account.state not in ['cancel', False]:
|
||||
if account.name not in account_moves:
|
||||
account_moves.append(account.name)
|
||||
if purchase.state not in ['cancel', 'draft', False]:
|
||||
purchase_orders.append(purchase.name)
|
||||
special_design = self.technology_design_ids.filtered(
|
||||
@@ -456,6 +461,9 @@ class MrpProduction(models.Model):
|
||||
if special.process_parameters_id not in process_parameters:
|
||||
process_parameters.append(special.process_parameters_id.display_name)
|
||||
|
||||
if account_moves:
|
||||
raise UserError(_("请联系工厂生产经理对该(%s)账单进行取消", ", ".join(account_moves)))
|
||||
|
||||
if purchase_orders:
|
||||
raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders)))
|
||||
if parameters_not:
|
||||
@@ -598,7 +606,8 @@ class MrpProduction(models.Model):
|
||||
elif self.tool_state == '2':
|
||||
manufacturing_type = 'invalid_tool_rework'
|
||||
res = {'programming_no': self.programming_no,
|
||||
'manufacturing_type': manufacturing_type}
|
||||
'manufacturing_type': manufacturing_type,
|
||||
'trigger_time': trigger_time}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
@@ -613,43 +622,43 @@ class MrpProduction(models.Model):
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
|
||||
# 增加对编程记录的更新
|
||||
cloud_programming = self._cron_get_programming_state()
|
||||
if manufacturing_type == 'rework':
|
||||
self.programming_record_ids.create({
|
||||
'number': len(self.programming_record_ids) + 1,
|
||||
'production_id': self.id,
|
||||
'reason': '返工',
|
||||
'programming_method': cloud_programming['programme_way'],
|
||||
'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
'target_production_id': cloud_programming['production_order_no'],
|
||||
'apply_time': trigger_time,
|
||||
'send_time': cloud_programming['send_time'],
|
||||
})
|
||||
elif manufacturing_type == 'scrap':
|
||||
self.programming_record_ids.create({
|
||||
'number': len(self.programming_record_ids) + 1,
|
||||
'production_id': self.id,
|
||||
'reason': '报废',
|
||||
'programming_method': cloud_programming['programme_way'],
|
||||
'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
'target_production_id': cloud_programming['production_order_no'],
|
||||
'apply_time': trigger_time,
|
||||
'send_time': cloud_programming['send_time'],
|
||||
})
|
||||
elif manufacturing_type == 'invalid_tool_rework':
|
||||
self.programming_record_ids.create({
|
||||
'number': len(self.programming_record_ids) + 1,
|
||||
'production_id': self.id,
|
||||
'reason': '无效功能刀具',
|
||||
'programming_method': cloud_programming['programme_way'],
|
||||
'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
'target_production_id': cloud_programming['production_order_no'],
|
||||
'apply_time': trigger_time,
|
||||
'send_time': cloud_programming['send_time'],
|
||||
})
|
||||
else:
|
||||
logging.info('无对应状态,不需更新编程记录')
|
||||
# # 增加对编程记录的更新
|
||||
# cloud_programming = self._cron_get_programming_state()
|
||||
# if manufacturing_type == 'rework':
|
||||
# self.programming_record_ids.create({
|
||||
# 'number': len(self.programming_record_ids) + 1,
|
||||
# 'production_id': self.id,
|
||||
# 'reason': '返工',
|
||||
# 'programming_method': cloud_programming['programme_way'],
|
||||
# 'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
# 'target_production_id': cloud_programming['production_order_no'],
|
||||
# 'apply_time': trigger_time,
|
||||
# 'send_time': cloud_programming['send_time'],
|
||||
# })
|
||||
# elif manufacturing_type == 'scrap':
|
||||
# self.programming_record_ids.create({
|
||||
# 'number': len(self.programming_record_ids) + 1,
|
||||
# 'production_id': self.id,
|
||||
# 'reason': '报废',
|
||||
# 'programming_method': cloud_programming['programme_way'],
|
||||
# 'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
# 'target_production_id': cloud_programming['production_order_no'],
|
||||
# 'apply_time': trigger_time,
|
||||
# 'send_time': cloud_programming['send_time'],
|
||||
# })
|
||||
# elif manufacturing_type == 'invalid_tool_rework':
|
||||
# self.programming_record_ids.create({
|
||||
# 'number': len(self.programming_record_ids) + 1,
|
||||
# 'production_id': self.id,
|
||||
# 'reason': '无效功能刀具',
|
||||
# 'programming_method': cloud_programming['programme_way'],
|
||||
# 'current_programming_count': cloud_programming['reprogramming_num'],
|
||||
# 'target_production_id': cloud_programming['production_order_no'],
|
||||
# 'apply_time': trigger_time,
|
||||
# 'send_time': cloud_programming['send_time'],
|
||||
# })
|
||||
# else:
|
||||
# logging.info('无对应状态,不需更新编程记录')
|
||||
|
||||
except Exception as e:
|
||||
logging.info('update_programming_state error:%s' % e)
|
||||
@@ -1541,7 +1550,9 @@ class MrpProduction(models.Model):
|
||||
group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id
|
||||
if not vals.get('procurement_group_id'):
|
||||
if product_id.product_tmpl_id.single_manufacturing:
|
||||
|
||||
if product_id.categ_id.name == '成品' and is_self_process:
|
||||
|
||||
vals['procurement_group_id'] = group_id
|
||||
continue
|
||||
if product_id.id not in product_group_id.keys():
|
||||
@@ -1694,6 +1705,7 @@ class MrpProduction(models.Model):
|
||||
logging.info('update_programming_state error:%s' % e)
|
||||
raise UserError("更新编程单状态失败,请联系管理员")
|
||||
|
||||
|
||||
# 编程记录
|
||||
class sf_programming_record(models.Model):
|
||||
_name = 'sf.programming.record'
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header//button[last()]" position="after">
|
||||
<button name="action_apply_programming" type="object" string="申请编程" class="oe_highlight"
|
||||
attrs="{'invisible': ['|', ('state', 'not in', ['confirmed', 'pending_cam']), ('programming_state', '!=', '已编程')]}"
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='state']" position="attributes">
|
||||
|
||||
@@ -39,6 +39,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
res = {'status': -2, 'message': '查询到待工艺确认的制造订单'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if productions:
|
||||
|
||||
# 拉取所有加工面的程序文件
|
||||
for r in ret['processing_panel'].split(','):
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
@@ -98,6 +99,18 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
||||
|
||||
# 对制造订单所有面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions}')
|
||||
re_tool_chekout = False
|
||||
re_tool_chekout = productions.production_cnc_tool_checkout()
|
||||
if re_tool_chekout:
|
||||
return json.JSONEncoder().encode({'status': -3, 'message': '对cnc工单的程序用刀进行校验失败'})
|
||||
except Exception as e:
|
||||
res = {'status': -3, 'message': '对cnc工单的程序用刀进行校验报错'}
|
||||
logging.info(f'对cnc工单的程序用刀进行校验报错:{e}')
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
# 更新编程记录
|
||||
for production in productions:
|
||||
record_ids_obj = production.programming_record_ids.filtered(
|
||||
@@ -115,7 +128,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
'apply_time': False,
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
if ret['reset_flag']:
|
||||
elif ret['reset_flag']:
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
@@ -126,23 +139,46 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
'apply_time': False,
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
elif ret['manufacturing_type'] == 'rework':
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
'reason': '返工',
|
||||
'programming_method': ret['programme_way'],
|
||||
'current_programming_count': ret['reprogramming_num'],
|
||||
'target_production_id': ret['production_order_no'],
|
||||
'apply_time': ret['trigger_time'],
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
elif ret['manufacturing_type'] == 'scrap':
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
'reason': '报废',
|
||||
'programming_method': ret['programme_way'],
|
||||
'current_programming_count': ret['reprogramming_num'],
|
||||
'target_production_id': ret['production_order_no'],
|
||||
'apply_time': ret['trigger_time'],
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
elif ret['manufacturing_type'] == 'invalid_tool_rework':
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
'reason': '无效功能刀具',
|
||||
'programming_method': ret['programme_way'],
|
||||
'current_programming_count': ret['reprogramming_num'],
|
||||
'target_production_id': ret['production_order_no'],
|
||||
'apply_time': ret['trigger_time'],
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
else:
|
||||
logging.info('无对应状态,不需更新编程记录')
|
||||
|
||||
res.update({
|
||||
'production_ids': productions.ids
|
||||
})
|
||||
|
||||
# 对制造订单所有面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions}')
|
||||
re_tool_chekout = False
|
||||
re_tool_chekout = productions.production_cnc_tool_checkout()
|
||||
if re_tool_chekout:
|
||||
return json.JSONEncoder().encode({'status': -3, 'message': '对cnc工单的程序用刀进行校验失败'})
|
||||
except Exception as e:
|
||||
# res = {'status': -2, 'message': '对cnc工单的程序用刀进行校验失败'}
|
||||
logging.info(f'对cnc工单的程序用刀进行校验报错:{e}')
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
return json.JSONEncoder().encode(res)
|
||||
else:
|
||||
res = {'status': 0, 'message': '没有查询到该制造订单'}
|
||||
|
||||
Reference in New Issue
Block a user