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

@@ -286,7 +286,7 @@ class ResMrpWorkOrder(models.Model):
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
picking_ids = fields.Many2many('stock.picking', string='外协出入库单', picking_ids = fields.Many2many('stock.picking', string='外协出入库单',
compute='_compute_surface_technics_picking_ids') compute='_compute_surface_technics_picking_ids', store=True)
purchase_id = fields.Many2many('purchase.order', string='外协采购单') purchase_id = fields.Many2many('purchase.order', string='外协采购单')
surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids') surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids')

View File

@@ -87,6 +87,12 @@ class SFSaleOrderCancelWizard(models.TransientModel):
for child_mo in child_mo_ids: for child_mo in child_mo_ids:
child_mo.action_cancel() 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() mo.action_cancel()
@@ -261,6 +267,7 @@ class SFSaleOrderCancelLine(models.TransientModel):
if purchase_orders: if purchase_orders:
e = 0 e = 0
for po in purchase_orders: for po in purchase_orders:
for order_line in po.order_line:
e += 1 e += 1
vals = { vals = {
'wizard_id': wizard_id, 'wizard_id': wizard_id,
@@ -270,8 +277,8 @@ class SFSaleOrderCancelLine(models.TransientModel):
'doc_number': po.name, 'doc_number': po.name,
'line_number': e, 'line_number': e,
'operation_type': '', 'operation_type': '',
'product_name': po.order_line[0].product_id.name if po.order_line else '', 'product_name': order_line.product_id.name if order_line else '',
'quantity': po.order_line[0].product_qty if po.order_line else 0, 'quantity': order_line.product_qty if order_line else 0,
'doc_state': map_dict.get(po.state, po.state), 'doc_state': map_dict.get(po.state, po.state),
'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else '' 'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
} }
@@ -329,6 +336,27 @@ class SFSaleOrderCancelLine(models.TransientModel):
lines.append(self.create(vals)) lines.append(self.create(vals))
sequence += 1 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: for move in mo.move_raw_ids:
# # 检查组件的采购单 # # 检查组件的采购单