编程单去重
This commit is contained in:
@@ -111,6 +111,18 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
doc_state = fields.Char('单据状态')
|
doc_state = fields.Char('单据状态')
|
||||||
cancel_reason = 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
|
@api.model
|
||||||
def create_from_order(self, wizard_id, order):
|
def create_from_order(self, wizard_id, order):
|
||||||
sequence = 1
|
sequence = 1
|
||||||
@@ -375,27 +387,26 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
# 检查制造订单的编程单
|
# 检查制造订单的编程单
|
||||||
cloud_programming = mo._cron_get_programming_state()
|
cloud_programming = mo._cron_get_programming_state()
|
||||||
if cloud_programming:
|
if cloud_programming:
|
||||||
vals = {
|
programming_no = cloud_programming['programming_no']
|
||||||
'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
|
|
||||||
|
|
||||||
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 = {}
|
# unique_lines = {}
|
||||||
# for line in lines:
|
# for line in lines:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<field name="doc_number" string="单据编号"/>
|
<field name="doc_number" string="单据编号"/>
|
||||||
<field name="line_number" string="行号"/>
|
<field name="line_number" string="行号"/>
|
||||||
<field name="product_name" string="产品名称"/>
|
<field name="product_name" string="产品名称"/>
|
||||||
<field name="quantity" string="数量"/>
|
<field name="quantity_str" string="数量"/>
|
||||||
<field name="doc_state" string="单据状态"/>
|
<field name="doc_state" string="单据状态"/>
|
||||||
<field name="cancel_reason" string="禁止取消原因"/>
|
<field name="cancel_reason" string="禁止取消原因"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
Reference in New Issue
Block a user