逾期工单不能批量重新安排的优化需求
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
<xpath expr="//tree/field[1]" position="before">
|
<xpath expr="//tree/field[1]" position="before">
|
||||||
<header>
|
<header>
|
||||||
<button string="重新安排" name="%(sf_manufacturing.mrp_workorder_batch_replan_wizard)d" type="action"
|
<button string="重新安排" name="%(sf_manufacturing.mrp_workorder_batch_replan_wizard)d" type="action"
|
||||||
class="treeHeaderBtn"/>
|
class="treeHeaderBtn"
|
||||||
|
invisible="context.get('workorder_type') not in ('工件装夹中心','1#自动生产线','工件拆卸中心')"/>
|
||||||
</header>
|
</header>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -22,15 +22,12 @@ class MrpWorkorderBatchReplanWizard(models.TransientModel):
|
|||||||
if active_ids:
|
if active_ids:
|
||||||
workorders = self.env['mrp.workorder'].browse(active_ids)
|
workorders = self.env['mrp.workorder'].browse(active_ids)
|
||||||
if workorders:
|
if workorders:
|
||||||
unique_types = set(workorders.mapped('type'))
|
routing_type = set(workorders.mapped('routing_type'))
|
||||||
return '/'.join(sorted(unique_types)) if unique_types else None
|
return '/'.join(sorted(routing_type)) if routing_type else None
|
||||||
return None
|
return None
|
||||||
|
|
||||||
workorder_type = fields.Char(string='工单类型', default=_get_default_workorder_type, readonly=True)
|
workorder_type = fields.Char(string='工单类型', default=_get_default_workorder_type, readonly=True)
|
||||||
|
|
||||||
date_planned_start = fields.Datetime(string='计划开始加工时间', index=True, copy=False,
|
|
||||||
default=_get_date_planned_start)
|
|
||||||
|
|
||||||
workorder_count = fields.Integer(string='工单数量',
|
workorder_count = fields.Integer(string='工单数量',
|
||||||
default=_get_default_workorder_count,
|
default=_get_default_workorder_count,
|
||||||
readonly=True)
|
readonly=True)
|
||||||
@@ -38,5 +35,36 @@ class MrpWorkorderBatchReplanWizard(models.TransientModel):
|
|||||||
workorder_id = fields.Many2many('mrp.workorder', string=u'工单')
|
workorder_id = fields.Many2many('mrp.workorder', string=u'工单')
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
print("ddd")
|
routing_type = set(self.workorder_id.mapped('routing_type'))
|
||||||
pass
|
if len(routing_type) > 1:
|
||||||
|
raise models.ValidationError("批量重新安排工单类型必须一致。")
|
||||||
|
show_json_popover = self.workorder_id.mapped('show_json_popover')
|
||||||
|
if any(not value for value in show_json_popover):
|
||||||
|
raise models.ValidationError("所选工单必须都为逾期状态")
|
||||||
|
failed_workorders = {}
|
||||||
|
for workorder_info in self.workorder_id:
|
||||||
|
try:
|
||||||
|
workorder_info.action_replan()
|
||||||
|
except Exception as e:
|
||||||
|
reason = str(e)
|
||||||
|
if reason in failed_workorders:
|
||||||
|
failed_workorders[reason].append(
|
||||||
|
workorder_info.production_id.name)
|
||||||
|
else:
|
||||||
|
failed_workorders[reason] = [workorder_info.production_id.name]
|
||||||
|
if failed_workorders:
|
||||||
|
error_messages = "\n".join(
|
||||||
|
[f"制造订单: {', '.join(workorder_names)}, 原因: {reason}" for reason, workorder_names in
|
||||||
|
failed_workorders.items()])
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.client',
|
||||||
|
'tag': 'display_notification',
|
||||||
|
'params': {
|
||||||
|
'message': f"以下工单重新安排失败:\n{error_messages}",
|
||||||
|
'sticky': False,
|
||||||
|
'color': 'red',
|
||||||
|
'next': {
|
||||||
|
'type': 'ir.actions.act_window_close'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
<form>
|
<form>
|
||||||
<group>
|
<group>
|
||||||
<field name="workorder_type"/>
|
<field name="workorder_type"/>
|
||||||
<field name="date_planned_start"/>
|
|
||||||
<field name="workorder_count"/>
|
<field name="workorder_count"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
@@ -20,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<record id="mrp_workorder_batch_replan_wizard" model="ir.actions.act_window">
|
<record id="mrp_workorder_batch_replan_wizard" model="ir.actions.act_window">
|
||||||
<field name="name">重新安排</field>
|
<field name="name">重新安排工单</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">mrp.workorder.batch.replan.wizard</field>
|
<field name="res_model">mrp.workorder.batch.replan.wizard</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<t t-if="record.workorder_count.raw_value > 0">
|
<t t-if="record.workorder_count.raw_value > 0">
|
||||||
<button class="btn btn-primary" name="action_work_order" type="object"
|
<button class="btn btn-primary" name="action_work_order" type="object"
|
||||||
attrs="{'invisible': [('name', '=', '功能刀具组装中心')]}"
|
attrs="{'invisible': [('name', '=', '功能刀具组装中心')]}"
|
||||||
context="{'search_default_ready': 1, 'search_default_progress': 1}">
|
context="{'search_default_ready': 1, 'search_default_progress': 1, 'workorder_type': name}">
|
||||||
<span>工单</span>
|
<span>工单</span>
|
||||||
</button>
|
</button>
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
Reference in New Issue
Block a user