在工单完成处控制状态,来避免非正常操作导致的制造订单状态异常问题

This commit is contained in:
mgw
2024-05-10 16:01:33 +08:00
parent e2d3b36683
commit d9543d42fd
3 changed files with 14 additions and 5 deletions

View File

@@ -214,8 +214,8 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'} res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
workorder.button_finish() workorder.button_finish()
workorder.process_state = '待解除装夹' # workorder.process_state = '待解除装夹'
workorder.sudo().production_id.process_state = '待解除装夹' # workorder.sudo().production_id.process_state = '待解除装夹'
# 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态 # 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态
if workorder.date_finished: if workorder.date_finished:

View File

@@ -67,7 +67,7 @@ class MrpProduction(models.Model):
('待加工', '待加工'), ('待加工', '待加工'),
('待解除装夹', '待解除装夹'), ('待解除装夹', '待解除装夹'),
('已完工', '已完工'), ('已完工', '已完工'),
], string='工序状态', related='workorder_ids.process_state', store=True) ], string='工序状态')
# 零件图号 # 零件图号
part_number = fields.Char('零件图号') part_number = fields.Char('零件图号')

View File

@@ -412,8 +412,8 @@ class ResMrpWorkOrder(models.Model):
work = workorder.production_id.workorder_ids work = workorder.production_id.workorder_ids
work.compensation_value_x = eval(self.material_center_point)[0] work.compensation_value_x = eval(self.material_center_point)[0]
work.compensation_value_y = eval(self.material_center_point)[1] work.compensation_value_y = eval(self.material_center_point)[1]
work.process_state = '待加工' # work.process_state = '待加工'
self.sudo().production_id.state = 'pending_processing' # self.sudo().production_id.process_state = '待加工'
self.date_finished = datetime.now() self.date_finished = datetime.now()
workorder.button_finish() workorder.button_finish()
@@ -828,6 +828,14 @@ class ResMrpWorkOrder(models.Model):
if not record.rfid_code: if not record.rfid_code:
raise UserError("请扫RFID码进行绑定") raise UserError("请扫RFID码进行绑定")
record.workpiece_delivery_ids[0].write({'status': '待下发'}) record.workpiece_delivery_ids[0].write({'status': '待下发'})
record.process_state = '待加工'
# record.write({'process_state': '待加工'})
record.production_id.process_state = '待加工'
if record.routing_type == 'CNC加工':
record.process_state = '待解除装夹'
# record.write({'process_state': '待加工'})
record.production_id.process_state = '待解除装夹'
if record.routing_type == '解除装夹': if record.routing_type == '解除装夹':
''' '''
@@ -869,6 +877,7 @@ class ResMrpWorkOrder(models.Model):
for move_raw_id in record.production_id.move_raw_ids: for move_raw_id in record.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty move_raw_id.quantity_done = move_raw_id.product_uom_qty
record.process_state = '已完工' record.process_state = '已完工'
record.production_id.process_state = '已完工'
record.production_id.button_mark_done1() record.production_id.button_mark_done1()
# self.production_id.state = 'done' # self.production_id.state = 'done'