From 52fa22989616c48e77089579d704372ce6e3298e Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 4 Jul 2024 17:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 29 ++++----- sf_manufacturing/models/mrp_production.py | 3 + sf_manufacturing/models/mrp_workorder.py | 1 - .../views/mrp_production_addional_change.xml | 63 +++++++++++++++++++ sf_manufacturing/views/mrp_workorder_view.xml | 2 +- 5 files changed, 82 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index a67be07d..ed3514b7 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -220,21 +220,22 @@ class Manufacturing_Connect(http.Controller): return json.JSONEncoder().encode(res) # workorder.write({'date_finished': datetime.now()}) if ret['IsComplete'] is True: - workorder.button_finish() - # workorder.process_state = '待解除装夹' - # workorder.sudo().production_id.process_state = '待解除装夹' + workorder.write({'date_finished': datetime.now()}) - # 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态 - # if workorder.date_finished: - # request.env['sf.production.plan'].sudo().search([('production_id', '=', production_id)]).write( - # {'actual_end_time': workorder.date_finished, - # 'state': 'finished'}) - # production_obj = request.env['mrp.production'].sudo().search([('name', '=', production_id)]) - # if production_obj: - # production_obj.sudo().work_order_state = '已完成' - # production_obj.write({'state': 'done'}) - # request.env['sale.order'].sudo().search( - # [('name', '=', production_obj.origin)]).write({'schedule_status': 'to deliver'}) + # workorder.process_state = '待解除装夹' + # workorder.sudo().production_id.process_state = '待解除装夹' + + # 根据工单的实际结束时间修改排程单的结束时间、状态,同时修改销售订单的状态 + # if workorder.date_finished: + # request.env['sf.production.plan'].sudo().search([('production_id', '=', production_id)]).write( + # {'actual_end_time': workorder.date_finished, + # 'state': 'finished'}) + # production_obj = request.env['mrp.production'].sudo().search([('name', '=', production_id)]) + # if production_obj: + # production_obj.sudo().work_order_state = '已完成' + # production_obj.write({'state': 'done'}) + # request.env['sale.order'].sudo().search( + # [('name', '=', production_obj.origin)]).write({'schedule_status': 'to deliver'}) except Exception as e: res = {'Succeed': False, 'ErrorCode': 202, 'Error': e} diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 107e6c7f..f0b88d63 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -102,6 +102,9 @@ class MrpProduction(models.Model): elif not production.workorder_ids and float_compare(production.qty_producing, production.product_qty, precision_rounding=production.product_uom_id.rounding) >= 0: production.state = 'to_close' + elif any( + wo.test_results == '返工' and wo.state == 'done' for wo in production.workorder_ids): + production.state = 'rework' elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')): production.state = 'progress' elif production.product_uom_id and not float_is_zero(production.qty_producing, diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ff1f9f2a..9182926d 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -957,7 +957,6 @@ class ResMrpWorkOrder(models.Model): # 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, diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 8396c4d3..8ddbb418 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -1,6 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + custom.mrp.production.tree mrp.production @@ -429,6 +481,17 @@ mrp.production + + + + + + + + + + +