From 050e82673a165a1df1c0a67eb121449926482f3d Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 4 Jul 2024 15:38:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96cnc=E5=B7=A5=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 14 ++++++++ sf_manufacturing/models/mrp_workorder.py | 17 +++++++--- .../views/mrp_production_addional_change.xml | 34 ++++++++++++++++++- sf_manufacturing/views/mrp_workorder_view.xml | 12 ++++--- sf_manufacturing/wizard/rework_wizard.py | 10 +++--- 5 files changed, 73 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 30a0770e..107e6c7f 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -716,3 +716,17 @@ class sf_detection_result(models.Model): test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格', string="检测结果", tracking=True) test_report = fields.Binary('检测报告', readonly=True) + + # 查看检测报告 + def button_look_test_report(self): + return { + 'res_model': 'sf.detection.result', + 'type': 'ir.actions.act_window', + 'res_id': self.id, + 'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')], + # 'view_mode': 'form', + # 'context': { + # 'default_id': self.id + # }, + 'target': 'new' + } diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 93d1b853..ff1f9f2a 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -47,6 +47,7 @@ class ResMrpWorkOrder(models.Model): ('切割', '切割'), ('表面工艺', '表面工艺') ], string="工序类型") results = fields.Char('结果') + state = fields.Selection(selection_add=[('to be detected', "待检测")]) manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) @@ -196,13 +197,14 @@ class ResMrpWorkOrder(models.Model): production_line_state = fields.Selection( [('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], string='上/下产线', default='待上产线', tracking=True) - detection_report = fields.Binary('检测报告', readonly=True) + detection_report = fields.Binary('检测报告', readonly=False) is_remanufacture = fields.Boolean(string='重新生成制造订单', default=False) is_fetchcnc = fields.Boolean(string='重新获取NC程序', default=False) reason = fields.Selection( - [("programming", "编程"), ("cutter", "刀具"), ("operate computer", "操机"), + [("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"), ("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True) detailed_reason = fields.Text('详细原因') + is_rework = fields.Boolean(string='是否返工', default=False) # is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False) @@ -473,8 +475,6 @@ class ResMrpWorkOrder(models.Model): 'default_production_ids': [(6, 0, [self.production_id.id])], }} - - # 拼接工单对象属性值 def json_workorder_str(self, k, production, route, item): # 计算预计时长duration_expected @@ -956,6 +956,15 @@ class ResMrpWorkOrder(models.Model): record.process_state = '待解除装夹' # record.write({'process_state': '待加工'}) record.production_id.process_state = '待解除装夹' + if record.test_results in ['返工']: + record.production_id.state = 'rework' + record.production_id.write({'detection_result_ids': [(0, 0, { + 'rework_reason': record.reason, + 'detailed_reason': record.detailed_reason, + 'processing_panel': record.processing_panel, + 'routing_type': record.routing_type, + 'test_results': record.test_results, + 'test_report': record.detection_report})]}) if record.routing_type == '解除装夹': ''' 记录结束时间 diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index fef027a7..8396c4d3 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -269,7 +269,20 @@ - + + + + + + + + + +