Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化

This commit is contained in:
mgw
2025-02-26 14:47:28 +08:00
2 changed files with 45 additions and 17 deletions

View File

@@ -87,6 +87,12 @@ class SFSaleOrderCancelWizard(models.TransientModel):
for child_mo in child_mo_ids:
child_mo.action_cancel()
# 取消工单的外协单
for workorder in mo.workorder_ids:
if workorder.picking_ids:
for pkd in workorder.picking_ids:
pkd.write({'state': 'cancel'})
# 取消制造订单
mo.action_cancel()
@@ -261,22 +267,23 @@ class SFSaleOrderCancelLine(models.TransientModel):
if purchase_orders:
e = 0
for po in purchase_orders:
e += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '制造',
'doc_name': '询价单',
'doc_number': po.name,
'line_number': e,
'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),
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
}
lines.append(self.create(vals))
sequence += 1
for order_line in po.order_line:
e += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '制造',
'doc_name': '询价单',
'doc_number': po.name,
'line_number': e,
'operation_type': '',
'product_name': order_line.product_id.name if order_line else '',
'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
# 检查制造订单的领料单
@@ -329,6 +336,27 @@ class SFSaleOrderCancelLine(models.TransientModel):
lines.append(self.create(vals))
sequence += 1
# 工艺外协处理
if workorder.picking_ids:
for pkd in workorder.picking_ids:
z = 0
for move in pkd.move_ids:
z += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '工艺外协',
'doc_name': '库存移动',
'doc_number': f'{mo.name}-{workorder.name}-{pkd.name}',
'line_number': z,
'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 ['cancel', 'waiting'] else ''
}
lines.append(self.create(vals))
# 检查制造订单组件的采购单和制造单
for move in mo.move_raw_ids:
# # 检查组件的采购单