Accept Merge Request #1875: (feature/制造功能优化 -> develop)

Merge Request: 完善单据

Created By: @马广威
Accepted By: @马广威
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1875?initial=true
This commit is contained in:
马广威
2025-02-27 11:00:19 +08:00
committed by Coding

View File

@@ -209,6 +209,31 @@ class SFSaleOrderCancelLine(models.TransientModel):
lines.append(self.create(vals))
sequence += 1
# 成品质检单
fin_quality_checks = self.env['quality.check'].search([
('picking_id', '=', picking.id)
])
if fin_quality_checks:
b1 = 0
for fin_qc in fin_quality_checks:
b1 += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '制造',
'doc_name': '质检单',
'operation_type': '',
'doc_number': fin_qc.name,
'line_number': b1,
'product_name': f'[{fin_qc.product_id.default_code}] {fin_qc.product_id.name}',
'quantity': 1,
'doc_state': map_dict.get(fin_qc.quality_state, fin_qc.quality_state),
'cancel_reason': '已有异动' if fin_qc.quality_state not in ['none', 'cancel', 'waiting'] else ''
}
lines.append(self.create(vals))
# 检查销售订单直接关联的采购单
purchase_orders = self.env['purchase.order'].search([
('origin', '=', order.name)
@@ -216,22 +241,71 @@ class SFSaleOrderCancelLine(models.TransientModel):
if purchase_orders:
c = 0
for po in purchase_orders:
c += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '采购',
'doc_name': '询价单',
'operation_type': '',
'doc_number': po.name,
'line_number': c,
'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),
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
}
lines.append(self.create(vals))
sequence += 1
for order_line in po.order_line:
c += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '采购',
'doc_name': '询价单',
'operation_type': '',
'doc_number': po.name,
'line_number': c,
'product_name': f'[{order_line.product_id.default_code}] {order_line.product_id.name}',
'quantity': order_line.product_qty if order_line else 0,
'doc_state': map_dict.get(po.state, po.state),
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
}
lines.append(self.create(vals))
sequence += 1
# 客供料的入库单
for pod in purchase_orders:
pkds = self.env['stock.picking'].search([
('origin', '=', pod.name)
])
if pkds:
for pkd in pkds:
x3 = 0
for move in pkd.move_ids:
x3 += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '客供料收货',
'doc_name': '库存移动',
'doc_number': pkd.name,
'line_number': x3,
'operation_type': pkd.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(pkd.state, pkd.state),
'cancel_reason': '已有异动' if pkd.state not in ['draft', 'cancel'] else ''
}
lines.append(self.create(vals))
#
for child_pkd in self.env['stock.picking'].search([
('origin', '=', pkd.name)
]):
x4 = 0
for child_move in child_pkd.move_ids:
x4 += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '客供料调拨',
'doc_name': '库存移动',
'doc_number': child_pkd.name,
'line_number': x4,
'operation_type': child_pkd.picking_type_id.name,
'product_name': child_move.product_id.name if child_move.product_id else '',
'quantity': child_move.product_uom_qty,
'doc_state': map_dict.get(child_pkd.state, child_pkd.state),
'cancel_reason': '已有异动' if child_pkd.state not in ['draft',
'cancel'] else ''
}
lines.append(self.create(vals))
# 检查制造订单
manufacturing_orders = self.env['mrp.production'].search([