修改退回工艺设计后再确认,采购单编程草稿状态

This commit is contained in:
胡尧
2024-12-31 11:39:36 +08:00
parent 9e5dbc0104
commit 64eb66c334
3 changed files with 17 additions and 14 deletions

View File

@@ -783,7 +783,7 @@ class MrpProduction(models.Model):
workorder.duration_expected = workorder._get_duration_expected()
# 外协出入库单处理
def get_subcontract_pick_purchase(self):
def get_subcontract_pick_purchase(self, special_design_workorder):
production_all = self.sorted(lambda x: x.id)
product_id_to_production_names = {}
grouped_product_ids = {k: list(g) for k, g in
@@ -792,18 +792,19 @@ class MrpProduction(models.Model):
product_id_to_production_names[product_id] = [p.name for p in pd]
sorted_workorders = None
for production in production_all:
proc_workorders = []
process_parameter_workorder = self.env['mrp.workorder'].search(
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc')
if process_parameter_workorder:
# 将这些特殊表面工艺工单的采购单与调拨单置为失效
for workorder in process_parameter_workorder:
workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'})
workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'})
# proc_workorders = []
# process_parameter_workorder = self.env['mrp.workorder'].search(
# [('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
# ('is_subcontract', '=', True), ('state', '!=', 'cancel')], order='sequence asc')
# need_delete_workorder = process_parameter_workorder - special_design_workorder
# for workorder in need_delete_workorder:
# workorder._get_surface_technics_purchase_ids().write({'active': False})
# workorder.move_subcontract_workorder_ids.write({'state': 'cancel'})
# workorder.move_subcontract_workorder_ids.picking_id.write({'active': False})
if special_design_workorder:
consecutive_workorders = []
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
sorted_workorders = sorted(special_design_workorder, key=lambda w: w.sequence)
# for i, workorder in enumerate(sorted_workorders):
# # 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
# if i == 0:

View File

@@ -57,6 +57,7 @@ class ProductionTechnologyWizard(models.TransientModel):
# td_upd = self.env['sf.technology.design'].sudo().search(domain)
# if td_upd:
# ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
# 特殊表面工艺
special_design = self.env['sf.technology.design'].sudo().search(
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
('is_auto', '=', False), ('active', 'in', [True, False])])
@@ -112,7 +113,9 @@ class ProductionTechnologyWizard(models.TransientModel):
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
productions._create_workorder(False)
if self.production_id.product_id.categ_id.type == '成品':
productions.get_subcontract_pick_purchase()
special_design_workorder = self.env['mrp.workorder'].search(
[('technology_design_id', 'in', special_design.ids), ('production_id', '=', special.production_id.id), ('state', '!=', 'cancel')])
productions.get_subcontract_pick_purchase(special_design_workorder)
productions.is_adjust = False
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(

View File

@@ -363,7 +363,6 @@ class RePurchaseOrder(models.Model):
server_product_process = []
purchase_order = pp._get_surface_technics_purchase_ids()
if purchase_order:
purchase_order.write({'state': 'draft'})
pp.purchase_id = [(6, 0, [purchase_order.id])]
else:
server_template = self.env['product.template'].search(