工艺确认统一工艺设计
This commit is contained in:
@@ -11,7 +11,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||
origin = fields.Char(string='源单据')
|
||||
is_technology_confirm = fields.Boolean(default=False)
|
||||
is_technology_confirm = fields.Boolean(default=True)
|
||||
|
||||
def confirm(self):
|
||||
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type in ['成品', '坯料']:
|
||||
@@ -19,40 +19,44 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
('product_id', '=', self.production_id.product_id.id)]
|
||||
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])])
|
||||
# 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:
|
||||
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 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[
|
||||
'sf.production.process.parameter'].search(
|
||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
'sequence': td_main.sequence})]})
|
||||
else:
|
||||
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 += [('id', '=', ro.id)]
|
||||
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})
|
||||
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs,
|
||||
production)
|
||||
# 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 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[
|
||||
# 'sf.production.process.parameter'].search(
|
||||
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||
# 'sequence': td_main.sequence})]})
|
||||
# else:
|
||||
# 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 += [('id', '=', ro.id)]
|
||||
# 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.id),
|
||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||
|
||||
Reference in New Issue
Block a user