制造订单的编程记录修改
This commit is contained in:
@@ -636,13 +636,17 @@ class MrpProduction(models.Model):
|
|||||||
# 增加触发时间参数
|
# 增加触发时间参数
|
||||||
def update_programming_state(self, trigger_time=None, reprogramming_reason=None):
|
def update_programming_state(self, trigger_time=None, reprogramming_reason=None):
|
||||||
try:
|
try:
|
||||||
|
reason = ""
|
||||||
manufacturing_type = None
|
manufacturing_type = None
|
||||||
if self.is_scrap:
|
if self.is_scrap:
|
||||||
manufacturing_type = 'scrap'
|
manufacturing_type = 'scrap'
|
||||||
|
reason = "报废"
|
||||||
elif self.tool_state == '2':
|
elif self.tool_state == '2':
|
||||||
manufacturing_type = 'invalid_tool_rework'
|
manufacturing_type = 'invalid_tool_rework'
|
||||||
|
reason = "无效功能刀具"
|
||||||
elif self.is_rework:
|
elif self.is_rework:
|
||||||
manufacturing_type = 'rework'
|
manufacturing_type = 'rework'
|
||||||
|
reason = "返工"
|
||||||
res = {'programming_no': self.programming_no,
|
res = {'programming_no': self.programming_no,
|
||||||
'manufacturing_type': manufacturing_type,
|
'manufacturing_type': manufacturing_type,
|
||||||
'trigger_time': trigger_time,
|
'trigger_time': trigger_time,
|
||||||
@@ -657,6 +661,16 @@ class MrpProduction(models.Model):
|
|||||||
result = json.loads(ret['result'])
|
result = json.loads(ret['result'])
|
||||||
logging.info('update_programming_state-ret:%s' % result)
|
logging.info('update_programming_state-ret:%s' % result)
|
||||||
if result['status'] == 1:
|
if result['status'] == 1:
|
||||||
|
self.programming_record_ids.create({
|
||||||
|
'number': len(self.programming_record_ids) + 1,
|
||||||
|
'production_id': self.id,
|
||||||
|
'reason': reason,
|
||||||
|
'programming_method': False,
|
||||||
|
'current_programming_count': False,
|
||||||
|
'target_production_id': False,
|
||||||
|
'apply_time': fields.Datetime.now(),
|
||||||
|
'send_time': False,
|
||||||
|
})
|
||||||
self.write({'is_rework': True})
|
self.write({'is_rework': True})
|
||||||
else:
|
else:
|
||||||
raise UserError(ret['message'])
|
raise UserError(ret['message'])
|
||||||
@@ -787,6 +801,17 @@ class MrpProduction(models.Model):
|
|||||||
if ret['status'] == 1:
|
if ret['status'] == 1:
|
||||||
self.write(
|
self.write(
|
||||||
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
||||||
|
# 生成编程记录
|
||||||
|
self.programming_record_ids.create({
|
||||||
|
'number': len(self.programming_record_ids) + 1,
|
||||||
|
'production_id': self.id,
|
||||||
|
'reason': '首次下发',
|
||||||
|
'programming_method': False,
|
||||||
|
'current_programming_count': False,
|
||||||
|
'target_production_id': False,
|
||||||
|
'apply_time': fields.Datetime.now(),
|
||||||
|
'send_time': False,
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
raise UserError(ret['message'])
|
raise UserError(ret['message'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1772,7 +1797,6 @@ class MrpProduction(models.Model):
|
|||||||
"""
|
"""
|
||||||
检查前置条件:制造订单【状态】=“待排程、待加工”,制造订单的【编程状态】=“已编程”。
|
检查前置条件:制造订单【状态】=“待排程、待加工”,制造订单的【编程状态】=“已编程”。
|
||||||
"""
|
"""
|
||||||
print('申请编程')
|
|
||||||
if len(self) > 1:
|
if len(self) > 1:
|
||||||
raise UserError('仅支持选择单个制造订单进行编程申请,请重新选择')
|
raise UserError('仅支持选择单个制造订单进行编程申请,请重新选择')
|
||||||
for production in self:
|
for production in self:
|
||||||
@@ -1841,6 +1865,7 @@ class sf_programming_record(models.Model):
|
|||||||
target_production_id = fields.Char('目标制造单号')
|
target_production_id = fields.Char('目标制造单号')
|
||||||
apply_time = fields.Datetime('申请时间')
|
apply_time = fields.Datetime('申请时间')
|
||||||
send_time = fields.Datetime('下发时间')
|
send_time = fields.Datetime('下发时间')
|
||||||
|
apply_uid = fields.Many2one('res.users', '申请人', default=lambda self: self.env.user)
|
||||||
|
|
||||||
|
|
||||||
class sf_detection_result(models.Model):
|
class sf_detection_result(models.Model):
|
||||||
|
|||||||
@@ -427,6 +427,7 @@
|
|||||||
<field name="programming_method"/>
|
<field name="programming_method"/>
|
||||||
<field name="current_programming_count"/>
|
<field name="current_programming_count"/>
|
||||||
<field name="target_production_id"/>
|
<field name="target_production_id"/>
|
||||||
|
<field name="apply_uid"/>
|
||||||
<field name="apply_time"/>
|
<field name="apply_time"/>
|
||||||
<field name="send_time"/>
|
<field name="send_time"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
@@ -147,25 +147,18 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
logging.info('record_ids_obj====:%s' % record_ids_obj)
|
logging.info('record_ids_obj====:%s' % record_ids_obj)
|
||||||
if record_ids_obj:
|
if record_ids_obj:
|
||||||
logging.info('record_ids_obj.reason====:%s' % record_ids_obj.reason)
|
logging.info('record_ids_obj.reason====:%s' % record_ids_obj.reason)
|
||||||
record_ids_obj.write(
|
record_ids_obj.write({
|
||||||
{'send_time': ret['send_time'], 'target_production_id': productions_reprogram})
|
'current_programming_count': ret['reprogramming_num'],
|
||||||
|
'send_time': ret['send_time'],
|
||||||
|
'target_production_id': productions_reprogram,
|
||||||
|
'programming_method': ret['programme_way']
|
||||||
|
})
|
||||||
logging.info('已更新编程记录:%s' % record_ids_obj)
|
logging.info('已更新编程记录:%s' % record_ids_obj)
|
||||||
correct_record_ids_obj = record_ids_obj
|
correct_record_ids_obj = record_ids_obj
|
||||||
correct_production_id = production.id
|
correct_production_id = production.id
|
||||||
if ret['reprogramming_num'] == 0:
|
# 更新重新编程记录
|
||||||
logging.info('首次下发')
|
else:
|
||||||
production.programming_record_ids.create({
|
if ret['reset_flag']:
|
||||||
'number': 1,
|
|
||||||
'production_id': production.id,
|
|
||||||
'reason': '首次下发',
|
|
||||||
'programming_method': ret['programme_way'],
|
|
||||||
'current_programming_count': ret['reprogramming_num'],
|
|
||||||
'target_production_id': productions_reprogram,
|
|
||||||
'apply_time': False,
|
|
||||||
'send_time': ret['send_time'],
|
|
||||||
})
|
|
||||||
logging.info('已创建首次下发的编程记录:%s' % production.name)
|
|
||||||
elif ret['reset_flag']:
|
|
||||||
logging.info('重置状态')
|
logging.info('重置状态')
|
||||||
production.programming_record_ids.create({
|
production.programming_record_ids.create({
|
||||||
'number': len(production.programming_record_ids) + 1,
|
'number': len(production.programming_record_ids) + 1,
|
||||||
@@ -177,60 +170,86 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
'apply_time': False,
|
'apply_time': False,
|
||||||
'send_time': ret['send_time'],
|
'send_time': ret['send_time'],
|
||||||
})
|
})
|
||||||
logging.info('已创建重置状态的编程记录:%s' % production.name)
|
|
||||||
elif ret['manufacturing_type'] == 'rework':
|
|
||||||
logging.info('返工')
|
|
||||||
rework_record_ids_obj = 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': productions_reprogram,
|
|
||||||
'apply_time': ret['trigger_time'],
|
|
||||||
'send_time': ret['send_time'],
|
|
||||||
})
|
|
||||||
logging.info('已创建返工的编程记录:%s' % production.name)
|
|
||||||
logging.info('rework_record_ids_obj====:%s' % rework_record_ids_obj)
|
|
||||||
# rework_production_id = production.id
|
|
||||||
# logging.info('rework_production_id====:%s' % rework_production_id)
|
|
||||||
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': productions_reprogram,
|
|
||||||
'apply_time': ret['trigger_time'],
|
|
||||||
'send_time': ret['send_time'],
|
|
||||||
})
|
|
||||||
elif ret['manufacturing_type'] == 'invalid_tool_rework':
|
|
||||||
logging.info('无效功能刀具')
|
|
||||||
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': productions_reprogram,
|
|
||||||
'apply_time': ret['trigger_time'],
|
|
||||||
'send_time': ret['send_time'],
|
|
||||||
})
|
|
||||||
logging.info('已创建无效功能刀具的编程记录:%s' % production.name)
|
|
||||||
elif ret['reprogramming_reason']:
|
|
||||||
production.programming_record_ids.create({
|
|
||||||
'number': len(production.programming_record_ids) + 1,
|
|
||||||
'production_id': production.id,
|
|
||||||
'reason': ret['reprogramming_reason'],
|
|
||||||
'programming_method': ret['programme_way'],
|
|
||||||
'current_programming_count': ret['reprogramming_num'],
|
|
||||||
'target_production_id': productions_reprogram,
|
|
||||||
'apply_time': ret['trigger_time'],
|
|
||||||
'send_time': ret['send_time'],
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
logging.info('无对应状态,不需更新编程记录')
|
logging.info('无对应状态,不需更新编程记录')
|
||||||
|
# if ret['reprogramming_num'] == 0:
|
||||||
|
# logging.info('首次下发')
|
||||||
|
# production.programming_record_ids.create({
|
||||||
|
# 'number': 1,
|
||||||
|
# 'production_id': production.id,
|
||||||
|
# 'reason': '首次下发',
|
||||||
|
# 'programming_method': ret['programme_way'],
|
||||||
|
# 'current_programming_count': ret['reprogramming_num'],
|
||||||
|
# 'target_production_id': productions_reprogram,
|
||||||
|
# 'apply_time': False,
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
# logging.info('已创建首次下发的编程记录:%s' % production.name)
|
||||||
|
# elif ret['reset_flag']:
|
||||||
|
# logging.info('重置状态')
|
||||||
|
# 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': productions_reprogram,
|
||||||
|
# 'apply_time': False,
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
# logging.info('已创建重置状态的编程记录:%s' % production.name)
|
||||||
|
# elif ret['manufacturing_type'] == 'rework':
|
||||||
|
# logging.info('返工')
|
||||||
|
# rework_record_ids_obj = 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': productions_reprogram,
|
||||||
|
# 'apply_time': ret['trigger_time'],
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
# logging.info('已创建返工的编程记录:%s' % production.name)
|
||||||
|
# logging.info('rework_record_ids_obj====:%s' % rework_record_ids_obj)
|
||||||
|
# # rework_production_id = production.id
|
||||||
|
# # logging.info('rework_production_id====:%s' % rework_production_id)
|
||||||
|
# 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': productions_reprogram,
|
||||||
|
# 'apply_time': ret['trigger_time'],
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
# elif ret['manufacturing_type'] == 'invalid_tool_rework':
|
||||||
|
# logging.info('无效功能刀具')
|
||||||
|
# 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': productions_reprogram,
|
||||||
|
# 'apply_time': ret['trigger_time'],
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
# logging.info('已创建无效功能刀具的编程记录:%s' % production.name)
|
||||||
|
# elif ret['reprogramming_reason']:
|
||||||
|
# production.programming_record_ids.create({
|
||||||
|
# 'number': len(production.programming_record_ids) + 1,
|
||||||
|
# 'production_id': production.id,
|
||||||
|
# 'reason': ret['reprogramming_reason'],
|
||||||
|
# 'programming_method': ret['programme_way'],
|
||||||
|
# 'current_programming_count': ret['reprogramming_num'],
|
||||||
|
# 'target_production_id': productions_reprogram,
|
||||||
|
# 'apply_time': ret['trigger_time'],
|
||||||
|
# 'send_time': ret['send_time'],
|
||||||
|
# })
|
||||||
|
|
||||||
|
|
||||||
for production in productions:
|
for production in productions:
|
||||||
logging.info('production====:%s' % production.name)
|
logging.info('production====:%s' % production.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user