Accept Merge Request #2180: (feature/搜索优化 -> develop)

Merge Request: 采购申请单完成操作提示调整

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2180
This commit is contained in:
管欢
2025-06-10 16:33:37 +08:00
committed by Coding
2 changed files with 33 additions and 24 deletions

View File

@@ -41,6 +41,7 @@ class PurchaseRequest(models.Model):
if lines: if lines:
for line in lines: for line in lines:
for line_item in line.order_line: for line_item in line.order_line:
if line_item.state == 'purchase':
product_id = line_item.product_id.id product_id = line_item.product_id.id
qty = line_item.product_qty qty = line_item.product_qty
product_rounding[product_id] = line_item.product_id.uom_id.rounding product_rounding[product_id] = line_item.product_id.uom_id.rounding
@@ -60,10 +61,10 @@ class PurchaseRequest(models.Model):
if discrepancies: if discrepancies:
# 弹出提示框 # 弹出提示框
message = "产品数量不一致:\n" message = "产品与采购数量不一致:\n"
for product_id, required_qty, order_qty in discrepancies: for product_id, required_qty, order_qty in discrepancies:
product_name = self.env['product.product'].browse(product_id).display_name # 获取产品名称 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 += "确认关闭?" message += "确认关闭?"
return { return {

View File

@@ -227,6 +227,14 @@ class ResMrpWorkOrder(models.Model):
# finish_move.move_dest_ids.move_line_ids.reserved_uom_qty = 0 # finish_move.move_dest_ids.move_line_ids.reserved_uom_qty = 0
else: else:
next_workorder = sorted_workorders[position + 1] next_workorder = sorted_workorders[position + 1]
# 持续获取下一个工单,直到找到一个不是返工的工单
while next_workorder and next_workorder.state == 'rework':
position += 1
if position + 1 < len(sorted_workorders):
next_workorder = sorted_workorders[position + 1]
else:
next_workorder = None
if next_workorder:
next_state = next_workorder.state next_state = next_workorder.state
if next_state not in ['pending', 'waiting', 'ready']: if next_state not in ['pending', 'waiting', 'ready']:
raise UserError('下工序已经开始,无法回退') raise UserError('下工序已经开始,无法回退')