调整调拨产品名称等
This commit is contained in:
@@ -162,22 +162,23 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
b = 0
|
||||
for picking in order.picking_ids:
|
||||
b += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '库存',
|
||||
'doc_name': '交货单',
|
||||
'operation_type': '调拨',
|
||||
'doc_number': picking.name,
|
||||
'line_number': b,
|
||||
'product_name': picking.product_id.name if picking.product_id else '',
|
||||
# 'quantity': picking.product_qty if hasattr(picking, 'product_qty') else 0,
|
||||
'quantity': sum(picking.move_ids.mapped('product_uom_qty') or [0]),
|
||||
'doc_state': map_dict.get(picking.state, picking.state),
|
||||
'cancel_reason': '已有异动' if picking.state not in ['draft', 'cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
for move in picking.move_ids:
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '库存',
|
||||
'doc_name': '交货单',
|
||||
'operation_type': '调拨',
|
||||
'doc_number': picking.name,
|
||||
'line_number': b,
|
||||
'product_name': f'[{move.product_id.default_code}] {move.product_id.name}' if move else '',
|
||||
# 'quantity': picking.product_qty if hasattr(picking, 'product_qty') else 0,
|
||||
'quantity': move.product_uom_qty,
|
||||
'doc_state': map_dict.get(picking.state, picking.state),
|
||||
'cancel_reason': '已有异动' if picking.state not in ['draft', 'cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
|
||||
# 检查销售订单直接关联的采购单
|
||||
purchase_orders = self.env['purchase.order'].search([
|
||||
@@ -192,7 +193,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'sequence': sequence,
|
||||
'category': '采购',
|
||||
'doc_name': '询价单',
|
||||
'operation_type': po.picking_type_id.name,
|
||||
'operation_type': '',
|
||||
'doc_number': po.name,
|
||||
'line_number': c,
|
||||
'product_name': po.order_line[0].product_id.name if po.order_line else '',
|
||||
@@ -219,7 +220,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'doc_number': mo.name,
|
||||
'operation_type': '',
|
||||
'line_number': d,
|
||||
'product_name': mo.product_id.name,
|
||||
'product_name': f'[{mo.product_id.default_code}] {mo.product_id.name}',
|
||||
'quantity': mo.product_qty,
|
||||
'doc_state': map_dict.get(mo.state, mo.state),
|
||||
'cancel_reason': '已有异动' if mo.state not in ['technology_to_confirmed', 'cancel'] else ''
|
||||
@@ -242,7 +243,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'doc_name': '询价单',
|
||||
'doc_number': po.name,
|
||||
'line_number': e,
|
||||
'operation_type': po.picking_type_id.name,
|
||||
'operation_type': '',
|
||||
'product_name': po.order_line[0].product_id.name if po.order_line else '',
|
||||
'quantity': po.order_line[0].product_qty if po.order_line else 0,
|
||||
'doc_state': map_dict.get(po.state, po.state),
|
||||
@@ -284,8 +285,8 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'doc_name': '工单',
|
||||
'doc_number': workorder.name,
|
||||
'line_number': g,
|
||||
'operation_type': workorder.workcenter_id.name,
|
||||
'product_name': mo.product_id.name,
|
||||
'operation_type': '',
|
||||
'product_name': f'[{mo.product_id.default_code}] {mo.product_id.name}',
|
||||
'quantity': workorder.qty_production,
|
||||
'doc_state': map_dict.get(workorder.state, workorder.state),
|
||||
'cancel_reason': '已有异动' if workorder.state not in ['draft', 'cancel', 'pending',
|
||||
@@ -336,7 +337,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'product_name': move.product_id.name,
|
||||
'quantity': comp_mo.product_qty,
|
||||
'doc_state': map_dict.get(comp_mo.state, comp_mo.state),
|
||||
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed'] else ''
|
||||
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed', 'cancel'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
@@ -357,10 +358,10 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'operation_type': '',
|
||||
'doc_number': check.name,
|
||||
'line_number': i,
|
||||
'product_name': check.product_id.name,
|
||||
'product_name': f'[{check.product_id.default_code}] {check.product_id.name}',
|
||||
'quantity': 1,
|
||||
'doc_state': map_dict.get(check.quality_state, check.quality_state),
|
||||
'cancel_reason': '已有异动' if check.quality_state not in ['none', 'cancel'] else ''
|
||||
'cancel_reason': '已有异动' if check.quality_state not in ['none', 'cancel', 'waiting'] else ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
@@ -376,19 +377,20 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'operation_type': '',
|
||||
'doc_number': cloud_programming['programming_no'],
|
||||
'line_number': 1,
|
||||
'product_name': cloud_programming['production_order_no'],
|
||||
'quantity': 1,
|
||||
'product_name': '',
|
||||
'quantity': '',
|
||||
'doc_state': cloud_programming['programming_state'],
|
||||
'cancel_reason': ''
|
||||
}
|
||||
lines.append(self.create(vals))
|
||||
sequence += 1
|
||||
return lines
|
||||
|
||||
unique_lines = {}
|
||||
for line in lines:
|
||||
doc_number = line.doc_number
|
||||
if doc_number not in unique_lines:
|
||||
unique_lines[doc_number] = line
|
||||
|
||||
# 返回去重后的记录列表
|
||||
return list(unique_lines.values())
|
||||
# unique_lines = {}
|
||||
# for line in lines:
|
||||
# doc_number = line.doc_number
|
||||
# if doc_number not in unique_lines:
|
||||
# unique_lines[doc_number] = line
|
||||
#
|
||||
# # 返回去重后的记录列表
|
||||
# return list(unique_lines.values())
|
||||
|
||||
Reference in New Issue
Block a user