批量处理工艺调整

This commit is contained in:
jinling.yang
2024-11-14 18:02:24 +08:00
parent 33a1837274
commit 018d51e25f
6 changed files with 158 additions and 95 deletions

View File

@@ -18,8 +18,24 @@ class ProductionTechnologyWizard(models.TransientModel):
domain = [('origin', '=', self.origin)]
else:
domain = [('id', '=', self.production_id.id)]
technology_designs = self.production_id.technology_design_ids
productions = self.env['mrp.production'].search(domain)
for production in productions:
if production != self.production_id:
for td_other in production.technology_design_ids:
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:
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[
'sf.production.process.parameter'].search(
[('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:
@@ -28,4 +44,5 @@ class ProductionTechnologyWizard(models.TransientModel):
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
workorder[0].state = 'waiting'
if workorder[0].state in ['pending']:
workorder[0].state = 'waiting'