From 9cf2bac9c6445d6c6a462f019b5b243d77b74d8f Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 9 Jun 2025 17:39:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=94=E5=B7=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 4cc1dae6..c5046722 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -227,22 +227,30 @@ class ResMrpWorkOrder(models.Model): # finish_move.move_dest_ids.move_line_ids.reserved_uom_qty = 0 else: next_workorder = sorted_workorders[position + 1] - next_state = next_workorder.state - if next_state not in ['pending', 'waiting', 'ready']: - raise UserError('下工序已经开始,无法回退') - if next_workorder.is_subcontract: - next_workorder.picking_ids.write({'state': 'waiting'}) - next_workorder.state = 'pending' - self.time_ids.date_end = None - cur_workorder.state = 'progress' - cur_workorder.production_id.state = 'progress' - quality_check = self.env['quality.check'].search( - [('workorder_id', '=', self.id)]) - for check_order in quality_check: - if check_order.point_id.is_inspect: - check_order.quality_state = 'waiting' + # 持续获取下一个工单,直到找到一个不是返工的工单 + while next_workorder and next_workorder.state == 'rework': + position += 1 + if position + 1 < len(sorted_workorders): + next_workorder = sorted_workorders[position + 1] else: - check_order.quality_state = 'none' + next_workorder = None + if next_workorder: + next_state = next_workorder.state + if next_state not in ['pending', 'waiting', 'ready']: + raise UserError('下工序已经开始,无法回退') + if next_workorder.is_subcontract: + next_workorder.picking_ids.write({'state': 'waiting'}) + next_workorder.state = 'pending' + self.time_ids.date_end = None + cur_workorder.state = 'progress' + cur_workorder.production_id.state = 'progress' + quality_check = self.env['quality.check'].search( + [('workorder_id', '=', self.id)]) + for check_order in quality_check: + if check_order.point_id.is_inspect: + check_order.quality_state = 'waiting' + else: + check_order.quality_state = 'none' def _compute_working_users(self): super()._compute_working_users() From a828c823dd6acd03e81272c131ae9b3fef8d4f36 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 9 Jun 2025 17:55:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=87=87=E8=B4=AD=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8D=95=E5=AE=8C=E6=88=90=E6=93=8D=E4=BD=9C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/purchase_request.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/jikimo_purchase_request/models/purchase_request.py b/jikimo_purchase_request/models/purchase_request.py index 0459dcd9..45e7457c 100644 --- a/jikimo_purchase_request/models/purchase_request.py +++ b/jikimo_purchase_request/models/purchase_request.py @@ -41,13 +41,14 @@ class PurchaseRequest(models.Model): if lines: for line in lines: for line_item in line.order_line: - product_id = line_item.product_id.id - qty = line_item.product_qty - product_rounding[product_id] = line_item.product_id.uom_id.rounding - if product_id in product_summary: - product_summary[product_id] += qty - else: - product_summary[product_id] = qty + if line_item.state == 'purchase': + product_id = line_item.product_id.id + qty = line_item.product_qty + product_rounding[product_id] = line_item.product_id.uom_id.rounding + if product_id in product_summary: + product_summary[product_id] += qty + else: + product_summary[product_id] = qty # 校验产品数量 discrepancies = [] @@ -63,7 +64,7 @@ class PurchaseRequest(models.Model): message = "产品数量不一致:\n" for product_id, required_qty, order_qty in discrepancies: product_name = self.env['product.product'].browse(product_id).display_name # 获取产品名称 - message += f"产品 {product_name},需求数量 {required_qty},关联采购订单数量 {order_qty}(含询价状态)\n" + message += f"产品 {product_name},需求数量 {required_qty},关联采购订单确认的数量 {order_qty},不一致,确认关闭?\n" # 添加确认框 message += "确认关闭?" return {