优化制造订单

This commit is contained in:
jinling.yang
2024-11-15 17:31:28 +08:00
parent 018d51e25f
commit 8add4b5ad1
6 changed files with 177 additions and 180 deletions

View File

@@ -17,43 +17,48 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed')]
else:
domain = [('id', '=', self.production_id.id)]
technology_designs = self.production_id.technology_design_ids
technology_designs = self.env['sf.technology.design'].sudo().search(
[('production_id', '=', self.production_id.id), ('active', 'in', [True, False])])
productions = self.env['mrp.production'].search(domain)
workorders_values = []
for production_my in productions:
for production_item in productions:
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
if production_my != self.production_id:
for td_other in production_my.technology_design_ids:
if production_item != self.production_id:
for td_other in production_item.technology_design_ids:
if td_other.is_auto is False:
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
if not td_del or td_del.active is False:
td_other.write({'active': False})
for td_main in technology_designs:
route_other = production_my.technology_design_ids.filtered(
route_other = production_item.technology_design_ids.filtered(
lambda td: td.route_id.id == td_main.route_id.id)
if not route_other:
production_my.write({'technology_design_ids': [(0, 0, {
if not route_other and td_main.active is True:
production_item.write({'technology_design_ids': [(0, 0, {
'route_id': td_main.route_id.id,
'process_parameters_id': False if td_main.process_parameters_id is False else
self.env[
'sf.production.process.parameter'].search(
[('id', '=', td_main.process_parameters_id.id)]).id,
'sequence': td_main.sequence})]})
'sequence': td_main.sequence,
'is_auto': td_main.is_auto})]})
else:
if td_main.route_id == td_other.route_id:
if td_main.route_id.routing_type == '表面工艺':
display_name = td_main.process_parameters_id.display_name
else:
display_name = td_main.route_id.display_name
if (td_main.panel is not False and td_main.panel == td_other.panel) or (
display_name == td_other.display_name):
if td_main.sequence != td_other.sequence:
td_other.write({'sequence': td_main.sequence})
logging.info(td_main.route_id.name)
logging.info(td_main.sequence)
logging.info(td_other.route_id.name)
logging.info(td_other.sequence)
for ro in route_other:
domain = [('production_id', '=', self.production_id.id), ('active', 'in', [True, False]),
('route_id', '=', ro.route_id.id)]
if ro.route_id.routing_type == '表面工艺':
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
display_name = ro.route_id.display_name
domain += [('name', 'ilike', display_name)]
elif ro.panel is not False:
domain += [('panel', '=', ro.panel)]
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_my.id),
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
('is_auto', '=', False), ('active', 'in', [True, False])])
for special in special_design:
workorders_values = []
if special.active is False:
# 工单采购单外协出入库单皆需取消
domain = [('production_id', '=', special.production_id.id)]
@@ -65,7 +70,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
if workorder.state != 'cancel':
workorder.write({'state': 'cancel'})
workorder.picking_ids.write({'state': 'cancel'})
# workorder.picking_ids.
workorder.picking_ids.move_ids.write({'state': 'cancel'})
purchase_order = self.env['purchase.order'].search(
[('origin', '=', workorder.production_id.origin)])
for line in purchase_order.order_line:
@@ -87,22 +92,20 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special,
product_production_process.seller_ids[
0].partner_id.id))
if special.process_parameters_id.gain_way == '外协':
special.production_id.get_subcontract_purchase()
else:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
special.production_id.write({'workorder_ids': workorders_values})
special.production_id.get_subcontract_pick()
special.production_id._reset_work_order_sequence()
workorders_values = []
special.production_id.write({'workorder_ids': workorders_values})
special.production_id.get_subcontract_pick()
else:
if len(workorder.blocked_by_workorder_ids) > 1:
if workorder.sequence == 1:
workorder.blocked_by_workorder_ids = None
else:
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
special.production_id._reset_work_order_sequence()
special.production_id.get_subcontract_pick_purchase()
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
workorder[0].state = 'waiting'
workorders[0].state = 'waiting'

View File

@@ -23,10 +23,14 @@ class ProductionTechnologyWizard(models.TransientModel):
for production in productions:
if production != self.production_id:
for td_other in production.technology_design_ids:
if td_other.is_auto is False:
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
if not td_del or td_del.active is False:
td_other.write({'active': False})
for td_main in technology_designs:
route_other = production.technology_design_ids.filtered(
lambda td: td.route_id.id == td_main.route_id.id)
if not route_other:
if not route_other and td_main.active is True:
production.write({'technology_design_ids': [(0, 0, {
'route_id': td_main.route_id.id,
'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
@@ -34,13 +38,25 @@ class ProductionTechnologyWizard(models.TransientModel):
[('id', '=', td_main.process_parameters_id.id)]).id,
'sequence': td_main.sequence})]})
else:
if td_main.sequence != td_other.sequence:
td_other.sequence = td_main.sequence
special = production.technology_design_ids.filtered(
lambda td: td.is_auto is False and td.process_parameters_id is not False)
if special:
production.get_subcontract_purchase()
for ro in route_other:
domain = [('production_id', '=', self.production_id.id),
('active', 'in', [True, False]),
('route_id', '=', ro.route_id.id)]
if ro.route_id.routing_type == '表面工艺':
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
display_name = ro.route_id.display_name
domain += [('name', 'ilike', display_name)]
elif ro.panel is not False:
domain += [('panel', '=', ro.panel)]
td_upd = self.env['sf.technology.design'].sudo().search(domain)
if td_upd:
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
# special = production.technology_design_ids.filtered(
# lambda td: td.is_auto is False and td.process_parameters_id is not False)
# # if special:
productions._create_workorder(False)
productions.get_subcontract_pick_purchase()
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)