From 37451259909782d205b82d47ab739ece75b59c20 Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Mon, 24 Feb 2025 16:59:12 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E5=8D=95=E5=8E=BB=E9=87=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_manufacturing/wizard/sale_order_cancel.py | 51 +++++++++++--------
.../wizard/sale_order_cancel_views.xml | 2 +-
2 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/sf_manufacturing/wizard/sale_order_cancel.py b/sf_manufacturing/wizard/sale_order_cancel.py
index 6a76f687..51d032b2 100644
--- a/sf_manufacturing/wizard/sale_order_cancel.py
+++ b/sf_manufacturing/wizard/sale_order_cancel.py
@@ -111,6 +111,18 @@ class SFSaleOrderCancelLine(models.TransientModel):
doc_state = fields.Char('单据状态')
cancel_reason = fields.Char('禁止取消原因')
+ quantity_str = fields.Char(
+ string="数量(字符串)",
+ compute="_compute_quantity_str",
+ store=False, # 默认不存储,除非需要搜索/排序
+ )
+
+ @api.depends("quantity")
+ def _compute_quantity_str(self):
+ for record in self:
+ # 处理所有可能的 False/0 情况
+ record.quantity_str = str(int(record.quantity)) if record.quantity not in [False, 0] else ""
+
@api.model
def create_from_order(self, wizard_id, order):
sequence = 1
@@ -375,27 +387,26 @@ class SFSaleOrderCancelLine(models.TransientModel):
# 检查制造订单的编程单
cloud_programming = mo._cron_get_programming_state()
if cloud_programming:
- vals = {
- 'wizard_id': wizard_id,
- 'sequence': sequence,
- 'category': '编程',
- 'doc_name': '编程单',
- 'operation_type': '',
- 'doc_number': cloud_programming['programming_no'],
- 'line_number': 1,
- 'product_name': '',
- 'quantity': '',
- 'doc_state': cloud_programming['programming_state'],
- 'cancel_reason': ''
- }
- program_list.append(self.create(vals))
- unique_lines = {}
- for line in program_list:
- doc_number = line.doc_number
- if doc_number not in unique_lines:
- unique_lines[doc_number] = line
+ programming_no = cloud_programming['programming_no']
- return lines + list(unique_lines.values())
+ # 检查当前lines中是否已存在相同doc_number的记录
+ if not any(line.doc_number == programming_no for line in lines):
+ vals = {
+ 'wizard_id': wizard_id,
+ 'sequence': sequence,
+ 'category': '编程',
+ 'doc_name': '编程单',
+ 'operation_type': '',
+ 'doc_number': programming_no, # 直接使用变量
+ 'line_number': 1,
+ 'product_name': '',
+ 'quantity': 0,
+ 'doc_state': cloud_programming['programming_state'],
+ 'cancel_reason': ''
+ }
+ lines.append(self.create(vals))
+
+ return lines
# unique_lines = {}
# for line in lines:
diff --git a/sf_manufacturing/wizard/sale_order_cancel_views.xml b/sf_manufacturing/wizard/sale_order_cancel_views.xml
index 6c07e31a..299af9e6 100644
--- a/sf_manufacturing/wizard/sale_order_cancel_views.xml
+++ b/sf_manufacturing/wizard/sale_order_cancel_views.xml
@@ -21,7 +21,7 @@
-
+