Accept Merge Request #1835: (feature/制造功能优化 -> develop)
Merge Request: 调整下游单据内容 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1835?initial=true
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': move.product_id.name.split('-')[-1] if move.product_id else '',
|
||||
'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 '',
|
||||
@@ -218,8 +219,8 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'doc_name': '制造订单',
|
||||
'doc_number': mo.name,
|
||||
'operation_type': '',
|
||||
'line_number': d,
|
||||
'product_name': mo.product_id.name,
|
||||
'line_number': mo.product_id.name.split('-')[-1] if mo.product_id else '',
|
||||
'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),
|
||||
@@ -256,21 +257,22 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
f = 0
|
||||
for picking in mo.picking_ids:
|
||||
f += 1
|
||||
vals = {
|
||||
'wizard_id': wizard_id,
|
||||
'sequence': sequence,
|
||||
'category': '制造',
|
||||
'doc_name': '库存移动',
|
||||
'doc_number': picking.name,
|
||||
'line_number': f,
|
||||
'operation_type': picking.picking_type_id.name,
|
||||
'product_name': picking.product_id.name if picking.product_id else '',
|
||||
'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': '库存移动',
|
||||
'doc_number': picking.name,
|
||||
'line_number': move.product_id.name.split(' ')[0].split('-')[-1] if move.product_id else '',
|
||||
'operation_type': picking.picking_type_id.name,
|
||||
'product_name': move.product_id.name if move.product_id else '',
|
||||
'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
|
||||
|
||||
# 检查制造订单的工单
|
||||
if mo.workorder_ids:
|
||||
@@ -283,9 +285,9 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'category': '制造',
|
||||
'doc_name': '工单',
|
||||
'doc_number': workorder.name,
|
||||
'line_number': g,
|
||||
'operation_type': workorder.workcenter_id.name,
|
||||
'product_name': mo.product_id.name,
|
||||
'line_number': mo.product_id.name.split('-')[-1] if mo.product_id else '',
|
||||
'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 +338,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
|
||||
@@ -356,11 +358,11 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
||||
'doc_name': '质检单',
|
||||
'operation_type': '',
|
||||
'doc_number': check.name,
|
||||
'line_number': i,
|
||||
'product_name': check.product_id.name,
|
||||
'line_number': check.product_id.name.split('-')[-1] if check.product_id else '',
|
||||
'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 +378,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