调整下游单据内容

This commit is contained in:
mgw
2025-02-24 14:46:18 +08:00
parent 91061b1eec
commit 555802b271

View File

@@ -170,7 +170,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
'doc_name': '交货单', 'doc_name': '交货单',
'operation_type': '调拨', 'operation_type': '调拨',
'doc_number': picking.name, 'doc_number': picking.name,
'line_number': b, '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 '', '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': picking.product_qty if hasattr(picking, 'product_qty') else 0,
'quantity': move.product_uom_qty, 'quantity': move.product_uom_qty,
@@ -219,7 +219,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
'doc_name': '制造订单', 'doc_name': '制造订单',
'doc_number': mo.name, 'doc_number': mo.name,
'operation_type': '', 'operation_type': '',
'line_number': d, '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}', '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),
@@ -257,21 +257,22 @@ class SFSaleOrderCancelLine(models.TransientModel):
f = 0 f = 0
for picking in mo.picking_ids: for picking in mo.picking_ids:
f += 1 f += 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': '制造',
'doc_number': picking.name, 'doc_name': '库存移动',
'line_number': f, 'doc_number': picking.name,
'operation_type': picking.picking_type_id.name, 'line_number': move.product_id.name.split(' ')[0].split('-')[-1] if move.product_id else '',
'product_name': picking.product_id.name if picking.product_id else '', 'operation_type': picking.picking_type_id.name,
'quantity': sum(picking.move_ids.mapped('product_uom_qty') or [0]), 'product_name': move.product_id.name if move.product_id else '',
'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
# 检查制造订单的工单 # 检查制造订单的工单
if mo.workorder_ids: if mo.workorder_ids:
@@ -284,7 +285,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
'category': '制造', 'category': '制造',
'doc_name': '工单', 'doc_name': '工单',
'doc_number': workorder.name, 'doc_number': workorder.name,
'line_number': g, 'line_number': mo.product_id.name.split('-')[-1] if mo.product_id else '',
'operation_type': '', 'operation_type': '',
'product_name': f'[{mo.product_id.default_code}] {mo.product_id.name}', 'product_name': f'[{mo.product_id.default_code}] {mo.product_id.name}',
'quantity': workorder.qty_production, 'quantity': workorder.qty_production,
@@ -357,7 +358,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
'doc_name': '质检单', 'doc_name': '质检单',
'operation_type': '', 'operation_type': '',
'doc_number': check.name, 'doc_number': check.name,
'line_number': i, '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}', '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),