完善单据
This commit is contained in:
@@ -209,6 +209,31 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
lines.append(self.create(vals))
|
lines.append(self.create(vals))
|
||||||
sequence += 1
|
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([
|
purchase_orders = self.env['purchase.order'].search([
|
||||||
('origin', '=', order.name)
|
('origin', '=', order.name)
|
||||||
@@ -216,22 +241,71 @@ class SFSaleOrderCancelLine(models.TransientModel):
|
|||||||
if purchase_orders:
|
if purchase_orders:
|
||||||
c = 0
|
c = 0
|
||||||
for po in purchase_orders:
|
for po in purchase_orders:
|
||||||
c += 1
|
for order_line in po.order_line:
|
||||||
vals = {
|
c += 1
|
||||||
'wizard_id': wizard_id,
|
vals = {
|
||||||
'sequence': sequence,
|
'wizard_id': wizard_id,
|
||||||
'category': '采购',
|
'sequence': sequence,
|
||||||
'doc_name': '询价单',
|
'category': '采购',
|
||||||
'operation_type': '',
|
'doc_name': '询价单',
|
||||||
'doc_number': po.name,
|
'operation_type': '',
|
||||||
'line_number': c,
|
'doc_number': po.name,
|
||||||
'product_name': po.order_line[0].product_id.name if po.order_line else '',
|
'line_number': c,
|
||||||
'quantity': po.order_line[0].product_qty if po.order_line else 0,
|
'product_name': f'[{order_line.product_id.default_code}] {order_line.product_id.name}',
|
||||||
'doc_state': map_dict.get(po.state, po.state),
|
'quantity': order_line.product_qty if order_line else 0,
|
||||||
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
|
'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
|
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([
|
manufacturing_orders = self.env['mrp.production'].search([
|
||||||
|
|||||||
Reference in New Issue
Block a user