修复返工问题
This commit is contained in:
@@ -227,22 +227,30 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# finish_move.move_dest_ids.move_line_ids.reserved_uom_qty = 0
|
# finish_move.move_dest_ids.move_line_ids.reserved_uom_qty = 0
|
||||||
else:
|
else:
|
||||||
next_workorder = sorted_workorders[position + 1]
|
next_workorder = sorted_workorders[position + 1]
|
||||||
next_state = next_workorder.state
|
# 持续获取下一个工单,直到找到一个不是返工的工单
|
||||||
if next_state not in ['pending', 'waiting', 'ready']:
|
while next_workorder and next_workorder.state == 'rework':
|
||||||
raise UserError('下工序已经开始,无法回退')
|
position += 1
|
||||||
if next_workorder.is_subcontract:
|
if position + 1 < len(sorted_workorders):
|
||||||
next_workorder.picking_ids.write({'state': 'waiting'})
|
next_workorder = sorted_workorders[position + 1]
|
||||||
next_workorder.state = 'pending'
|
|
||||||
self.time_ids.date_end = None
|
|
||||||
cur_workorder.state = 'progress'
|
|
||||||
cur_workorder.production_id.state = 'progress'
|
|
||||||
quality_check = self.env['quality.check'].search(
|
|
||||||
[('workorder_id', '=', self.id)])
|
|
||||||
for check_order in quality_check:
|
|
||||||
if check_order.point_id.is_inspect:
|
|
||||||
check_order.quality_state = 'waiting'
|
|
||||||
else:
|
else:
|
||||||
check_order.quality_state = 'none'
|
next_workorder = None
|
||||||
|
if next_workorder:
|
||||||
|
next_state = next_workorder.state
|
||||||
|
if next_state not in ['pending', 'waiting', 'ready']:
|
||||||
|
raise UserError('下工序已经开始,无法回退')
|
||||||
|
if next_workorder.is_subcontract:
|
||||||
|
next_workorder.picking_ids.write({'state': 'waiting'})
|
||||||
|
next_workorder.state = 'pending'
|
||||||
|
self.time_ids.date_end = None
|
||||||
|
cur_workorder.state = 'progress'
|
||||||
|
cur_workorder.production_id.state = 'progress'
|
||||||
|
quality_check = self.env['quality.check'].search(
|
||||||
|
[('workorder_id', '=', self.id)])
|
||||||
|
for check_order in quality_check:
|
||||||
|
if check_order.point_id.is_inspect:
|
||||||
|
check_order.quality_state = 'waiting'
|
||||||
|
else:
|
||||||
|
check_order.quality_state = 'none'
|
||||||
|
|
||||||
def _compute_working_users(self):
|
def _compute_working_users(self):
|
||||||
super()._compute_working_users()
|
super()._compute_working_users()
|
||||||
|
|||||||
Reference in New Issue
Block a user