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