1.工单状态新增‘返工’,2,在制造订单上点击返工选择加工面确认后,新增加工面的对应工单及新增重置cloud的编程单的状态3.优化返工向导

This commit is contained in:
jinling.yang
2024-07-09 17:36:47 +08:00
parent b383a6d229
commit 7533d23d3e
5 changed files with 100 additions and 74 deletions

View File

@@ -12,7 +12,7 @@ class ReworkWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单')
product_id = fields.Many2one('product.product')
production_ids = fields.Many2many('mrp.production', string='制造订单号')
production_id = fields.Many2one('mrp.production', string='制造订单号')
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
@@ -23,17 +23,38 @@ class ReworkWizard(models.TransientModel):
('CNC加工', 'CNC加工')], string="工序类型")
# 根据工单的加工面来显示
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
def confirm(self):
if len(self.production_ids) == 1:
if self.is_reprogramming is True:
if self.production_id.workorder_ids:
panel_workorder = self.production_id.workorder_ids.filtered(
lambda ap: ap.processing_panel == self.processing_panel_id.name)
if panel_workorder:
panel_workorder.write({'state': 'rework'})
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
order='sequence asc'
)
workorders_values = []
for route in product_routing_workcenter:
if route.is_repeat is True:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(self.processing_panel_id.name,
self.production_id, route, False))
if workorders_values:
self.production_id.write({'workorder_ids': workorders_values, 'programming_state': '编程中'})
self.production_id._reset_work_order_sequence()
self.production_id.update_programming_state()
else:
self.workorder_id.is_rework = True
self.production_ids.write({'detection_result_ids': [(0, 0, {
'rework_reason': self.rework_reason,
'detailed_reason': self.detailed_reason,
# 'processing_panel': self.workorder_id.processing_panel,
'routing_type': self.workorder_id.routing_type,
'test_results': self.workorder_id.test_results,
'test_report': self.workorder_id.detection_report})]})
self.production_id.write({'detection_result_ids': [(0, 0, {
'rework_reason': self.rework_reason,
'detailed_reason': self.detailed_reason,
# 'processing_panel': self.workorder_id.processing_panel,
'routing_type': self.workorder_id.routing_type,
'test_results': self.workorder_id.test_results,
'test_report': self.workorder_id.detection_report})]})
@api.onchange('product_id')
def onchange_processing_panel_id(self):
@@ -50,4 +71,3 @@ class ReworkWizard(models.TransientModel):
panel_ids.append(panel.id)
domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
return {'domain': domain}

View File

@@ -6,13 +6,17 @@
<field name="arch" type="xml">
<form>
<sheet>
<field name="production_ids" invisible="True"/>
<field name="production_id" invisible="True"/>
<field name="workorder_id" invisible="True"/>
<field name="product_id" invisible="True"/>
<group>
<field name="processing_panel_id" options="{'no_create': True}" />
<field name="rework_reason" required="1"/>
<field name="detailed_reason" required="1"/>
<field name="processing_panel_id" options="{'no_create': True}"/>
<field name="is_reprogramming"
attrs='{"invisible": [("is_reprogramming","=",False)],"readonly": [("is_reprogramming","=",True)]}'/>
<field name="rework_reason"
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
<field name="detailed_reason"
attrs='{"invisible": [("is_reprogramming","=",True)],"required": [("is_reprogramming","=",False)]}'/>
</group>
<footer>
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认返工"/>