Merge branch 'feature/返工优化_5' into feature/工序排序优化

This commit is contained in:
yuxianghui
2024-11-27 11:01:49 +08:00
3 changed files with 33 additions and 11 deletions

View File

@@ -891,6 +891,14 @@ class MrpProduction(models.Model):
and item.panel == work.processing_panel))
if td_ids:
work.sequence = td_ids[0].sequence
cancel_work_ids = workorder_ids.filtered(lambda item: item.state in ('已取消', 'cancel'))
if cancel_work_ids:
sequence = max(workorder_ids.filtered(lambda item: item.state not in ('已取消', 'cancel')),
key=lambda w: w.sequence).sequence
for cw in cancel_work_ids:
cw.sequence = sequence + 1
def _reset_work_order_sequence_1(self):
"""
@@ -1142,13 +1150,13 @@ class MrpProduction(models.Model):
if self.programming_state in ['已编程']:
cloud_programming = self._cron_get_programming_state()
result_ids = self.detection_result_ids.filtered(lambda dr: dr.handle_result == '待处理')
work_ids = []
work_id_list = []
if result_ids:
for result_id in result_ids:
work_ids.append(self.workorder_ids.filtered(
lambda wk: (wk.name == result_id.routing_type
and wk.processing_panel == result_id.processing_panel
and wk.state == 'done')).id)
work_id_list = [self.workorder_ids.filtered(
lambda wk: (wk.name == result_id.routing_type and wk.processing_panel == result_id.processing_panel
and wk.state == 'done')).id
for result_id in result_ids]
return {
'name': _('返工'),
'type': 'ir.actions.act_window',
@@ -1157,7 +1165,8 @@ class MrpProduction(models.Model):
'target': 'new',
'context': {
'default_production_id': self.id,
'default_workorder_ids': work_ids,
'default_workorder_ids': self.workorder_ids.ids,
'default_hidden_workorder_ids': ','.join(map(str, work_id_list)) if work_id_list != [] else '',
'default_reprogramming_num': cloud_programming['reprogramming_num'],
'default_programming_state': cloud_programming['programming_state'],
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False