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

Merge Request: 组件制造调拨外置

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

View File

@@ -254,6 +254,51 @@ class SFSaleOrderCancelLine(models.TransientModel):
} }
lines.append(self.create(vals)) lines.append(self.create(vals))
# 检查组件的制造单
# component_mos = self.env['mrp.production'].search([
# ('origin', '=', mo.name)])
component_mos = self.env['mrp.production'].search([
('product_id.name', 'like', f'%R-{order.name}%')])
h = 0
if component_mos:
for comp_mo in component_mos:
h += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '制造',
'doc_name': '组件制造单',
'operation_type': '',
'doc_number': comp_mo.name,
'line_number': h,
'product_name': f'{comp_mo.product_id.name}',
'quantity': comp_mo.product_qty,
'doc_state': map_dict.get(comp_mo.state, comp_mo.state),
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed',
'cancel'] else ''
}
lines.append(self.create(vals))
sequence += 1
for pinking_id in comp_mo.picking_ids:
y = 0
for move in pinking_id.move_ids:
y += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '子制造调拨',
'doc_name': '库存移动',
'doc_number': f'{comp_mo.name}-{pinking_id.name}',
'line_number': y,
'operation_type': pinking_id.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(pinking_id.state, pinking_id.state),
'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting',
'assigned'] else ''
}
lines.append(self.create(vals))
# 检查销售订单直接关联的采购单 # 检查销售订单直接关联的采购单
purchase_orders = self.env['purchase.order'].search([ purchase_orders = self.env['purchase.order'].search([
@@ -499,73 +544,28 @@ class SFSaleOrderCancelLine(models.TransientModel):
} }
lines.append(self.create(vals)) lines.append(self.create(vals))
# 检查制造订单组件的采购单和制造单 # # 检查制造订单组件的采购单和制造单
for move in mo.move_raw_ids: # for move in mo.move_raw_ids:
# # 检查组件的采购单 # # 检查组件的采购单
# component_pos = self.env['purchase.order'].search([ # component_pos = self.env['purchase.order'].search([
# ('origin', '=', mo.name), # ('origin', '=', mo.name),
# ('order_line.product_id', '=', move.product_id.id) # ('order_line.product_id', '=', move.product_id.id)
# ]) # ])
# for po in component_pos: # for po in component_pos:
# vals = { # vals = {
# 'wizard_id': wizard_id, # 'wizard_id': wizard_id,
# 'sequence': sequence, # 'sequence': sequence,
# 'category': '制造', # 'category': '制造',
# 'doc_name': '组件采购单', # 'doc_name': '组件采购单',
# 'operation_type': '组件采购', # 'operation_type': '组件采购',
# 'doc_number': po.name, # 'doc_number': po.name,
# 'product_name': move.product_id.name, # 'product_name': move.product_id.name,
# 'quantity': po.order_line[0].product_qty if po.order_line else 0, # 'quantity': po.order_line[0].product_qty if po.order_line else 0,
# 'doc_state': po.state, # 'doc_state': po.state,
# 'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else '' # 'cancel_reason': '已有异动' if po.state not in ['draft', 'cancel'] else ''
# } # }
# lines.append(self.create(vals)) # lines.append(self.create(vals))
# sequence += 1 # sequence += 1
# 检查组件的制造单
# component_mos = self.env['mrp.production'].search([
# ('origin', '=', mo.name)])
component_mos = self.env['mrp.production'].search([
('product_id.name', 'like', f'%R-{order.name}%')])
h = 0
if component_mos:
for comp_mo in component_mos:
h += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '制造',
'doc_name': '组件制造单',
'operation_type': '',
'doc_number': comp_mo.name,
'line_number': h,
'product_name': f'{comp_mo.product_id.name}',
'quantity': comp_mo.product_qty,
'doc_state': map_dict.get(comp_mo.state, comp_mo.state),
'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed',
'cancel'] else ''
}
lines.append(self.create(vals))
sequence += 1
for pinking_id in comp_mo.picking_ids:
y = 0
for move in pinking_id.move_ids:
y += 1
vals = {
'wizard_id': wizard_id,
'sequence': sequence,
'category': '子制造调拨',
'doc_name': '库存移动',
'doc_number': f'{comp_mo.name}-{pinking_id.name}',
'line_number': y,
'operation_type': pinking_id.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(pinking_id.state, pinking_id.state),
'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting', 'assigned'] else ''
}
lines.append(self.create(vals))
# # 检查制造订单的质检单 # # 检查制造订单的质检单
# quality_checks = self.env['quality.check'].search([ # quality_checks = self.env['quality.check'].search([