Accept Merge Request #1639: (feature/part_number -> develop)
Merge Request: 工艺确认统一工艺设计 Created By: @廖丹龙 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @廖丹龙 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1639
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
from odoo import fields, models, api, _
|
from odoo import fields, models, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
@@ -6,7 +8,7 @@ from odoo.exceptions import ValidationError
|
|||||||
class sf_technology_design(models.Model):
|
class sf_technology_design(models.Model):
|
||||||
_name = 'sf.technology.design'
|
_name = 'sf.technology.design'
|
||||||
_description = "工艺设计"
|
_description = "工艺设计"
|
||||||
|
group_uniq_id = fields.Integer('同一制造订单唯一id',default=0)
|
||||||
sequence = fields.Integer('序号')
|
sequence = fields.Integer('序号')
|
||||||
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
route_id = fields.Many2one('mrp.routing.workcenter', '工序')
|
||||||
process_parameters_id = fields.Many2one('sf.production.process.parameter', string='表面工艺参数')
|
process_parameters_id = fields.Many2one('sf.production.process.parameter', string='表面工艺参数')
|
||||||
@@ -17,6 +19,11 @@ class sf_technology_design(models.Model):
|
|||||||
is_auto = fields.Boolean('是否自动生成', default=False)
|
is_auto = fields.Boolean('是否自动生成', default=False)
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
# @api.depends('production_id')
|
||||||
|
# def _compute_group_uniq_id(self):
|
||||||
|
# for record in self:
|
||||||
|
|
||||||
|
|
||||||
def json_technology_design_str(self, k, route, i, process_parameter):
|
def json_technology_design_str(self, k, route, i, process_parameter):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
||||||
@@ -28,6 +35,9 @@ class sf_technology_design(models.Model):
|
|||||||
'is_auto': True}]
|
'is_auto': True}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
print('qwfojkqwfkio')
|
||||||
|
return super(sf_technology_design, self).write(vals)
|
||||||
def unlink_technology_design(self):
|
def unlink_technology_design(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
@@ -37,4 +47,63 @@ class sf_technology_design(models.Model):
|
|||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if not vals.get('route_id'):
|
if not vals.get('route_id'):
|
||||||
raise ValidationError(_("工序不能为空"))
|
raise ValidationError(_("工序不能为空"))
|
||||||
return super(sf_technology_design, self).create(vals_list)
|
result = super(sf_technology_design, self).create(vals_list)
|
||||||
|
for res in result:
|
||||||
|
record = self.search([('production_id', '=', res.production_id.id), ('active', 'in', [True, False])], order='group_uniq_id desc', limit=1)
|
||||||
|
res.group_uniq_id=record.group_uniq_id + 1
|
||||||
|
return result
|
||||||
|
def get_duplicates_with_inactive(self,technology_designs):
|
||||||
|
# 统计每个 'sequence' 出现的次数
|
||||||
|
sequence_count = Counter(technology_design.sequence for technology_design in technology_designs)
|
||||||
|
|
||||||
|
# 筛选出 'sequence' 重复且 'active' 为 False 的元素
|
||||||
|
result = [
|
||||||
|
technology_design for technology_design in technology_designs
|
||||||
|
if sequence_count[technology_design.sequence] > 1 and technology_design.active is False
|
||||||
|
]
|
||||||
|
|
||||||
|
return result
|
||||||
|
# def rearrange_numbering(self,self_technology_designs):
|
||||||
|
# inactive_designs = self.get_duplicates_with_inactive(self_technology_designs)
|
||||||
|
# if inactive_designs:
|
||||||
|
# max_design = max(self_technology_designs, key=lambda x: x.sequence)
|
||||||
|
# max_sequence = max_design.sequence if max_design else 0
|
||||||
|
# for designs in inactive_designs:
|
||||||
|
# max_sequence += 1
|
||||||
|
# designs.sequence = max_sequence
|
||||||
|
# self_technology_designs.sorted(key=lambda techology_design:techology_design.sequence)
|
||||||
|
# return self_technology_designs
|
||||||
|
|
||||||
|
def get_technology_design(self):
|
||||||
|
return {
|
||||||
|
'sequence':self.sequence,
|
||||||
|
'route_id': self.route_id.id,
|
||||||
|
'process_parameters_id': self.process_parameters_id.id,
|
||||||
|
'panel': self.panel,
|
||||||
|
'routing_tag': self.routing_tag,
|
||||||
|
'time_cycle_manual': self.time_cycle_manual,
|
||||||
|
'is_auto': self.is_auto,
|
||||||
|
'active': self.active,
|
||||||
|
'group_uniq_id':self.group_uniq_id,
|
||||||
|
}
|
||||||
|
def sync_technology_designs(self,production_technology_designs, self_technology_designs):
|
||||||
|
production_id = production_technology_designs[0].production_id.id
|
||||||
|
self_technology_design_dict = {item.group_uniq_id:item for item in self_technology_designs}
|
||||||
|
production_technology_designs_dict = {item.group_uniq_id:item for item in production_technology_designs}
|
||||||
|
for technology_design in production_technology_designs:
|
||||||
|
if not self_technology_design_dict.get(technology_design.group_uniq_id):
|
||||||
|
technology_design.write({'production_id': False})
|
||||||
|
else:
|
||||||
|
technology_design.write(self_technology_design_dict.get(technology_design.group_uniq_id).get_technology_design())
|
||||||
|
for technology_design in self_technology_designs:
|
||||||
|
if not production_technology_designs_dict.get(technology_design.group_uniq_id):
|
||||||
|
technology_design = technology_design.get_technology_design()
|
||||||
|
technology_design.update({'production_id': production_id})
|
||||||
|
self.env['sf.technology.design'].create(technology_design)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def unified_procedure_multiple_work_orders(self,self_technology_designs,production_item):
|
||||||
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
|
[('production_id', '=', production_item.id), ('active', 'in', [True, False])])
|
||||||
|
self.sync_technology_designs(self_technology_designs=self_technology_designs,production_technology_designs=technology_designs)
|
||||||
@@ -10,7 +10,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
|
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
origin = fields.Char(string='源单据')
|
origin = fields.Char(string='源单据')
|
||||||
is_technology_re_adjust = fields.Boolean(default=False)
|
is_technology_re_adjust = fields.Boolean(default=True)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_re_adjust is True:
|
if self.is_technology_re_adjust is True:
|
||||||
@@ -24,38 +24,39 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
# 该制造订单的其他同一销售订单的制造订单的工艺设计处理
|
||||||
if production_item != self.production_id:
|
if production_item != self.production_id:
|
||||||
for td_other in production_item.technology_design_ids:
|
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs, production_item)
|
||||||
if td_other.is_auto is False:
|
# for td_other in production_item.technology_design_ids:
|
||||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
# # if td_other.is_auto is False:
|
||||||
if not td_del or td_del.active is False:
|
# # td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
td_other.write({'active': False})
|
# # if not td_del or td_del.active is False:
|
||||||
for td_main in technology_designs:
|
# # td_other.write({'active': False})
|
||||||
route_other = production_item.technology_design_ids.filtered(
|
# for td_main in technology_designs:
|
||||||
lambda td: td.route_id.id == td_main.route_id.id)
|
# route_other = production_item.technology_design_ids.filtered(
|
||||||
if not route_other and td_main.active is True:
|
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
production_item.write({'technology_design_ids': [(0, 0, {
|
# if not route_other and td_main.active is True:
|
||||||
'route_id': td_main.route_id.id,
|
# production_item.write({'technology_design_ids': [(0, 0, {
|
||||||
'process_parameters_id': False if td_main.process_parameters_id is False else
|
# 'route_id': td_main.route_id.id,
|
||||||
self.env[
|
# 'process_parameters_id': False if td_main.process_parameters_id is False else
|
||||||
'sf.production.process.parameter'].search(
|
# self.env[
|
||||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
# 'sf.production.process.parameter'].search(
|
||||||
'sequence': td_main.sequence,
|
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
'is_auto': td_main.is_auto})]})
|
# 'sequence': td_main.sequence,
|
||||||
else:
|
# 'is_auto': td_main.is_auto})]})
|
||||||
for ro in route_other:
|
# else:
|
||||||
domain = [('production_id', '=', self.production_id.id),
|
# for ro in route_other:
|
||||||
('active', 'in', [True, False]),
|
# domain = [('production_id', '=', self.production_id.id),
|
||||||
('route_id', '=', ro.route_id.id)]
|
# ('active', 'in', [True, False]),
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
# ('route_id', '=', ro.route_id.id)]
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
# if ro.route_id.routing_type == '表面工艺':
|
||||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
# display_name = ro.route_id.display_name
|
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
domain += [('id', '=', ro.id)]
|
# # display_name = ro.route_id.display_name
|
||||||
elif ro.panel is not False:
|
# domain += [('id', '=', ro.id)]
|
||||||
domain += [('panel', '=', ro.panel)]
|
# elif ro.panel is not False:
|
||||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
# domain += [('panel', '=', ro.panel)]
|
||||||
if td_upd:
|
# td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
||||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
# if td_upd:
|
||||||
|
# ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
||||||
special_design = self.env['sf.technology.design'].sudo().search(
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
[('routing_tag', '=', 'special'), ('production_id', '=', production_item.id),
|
||||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
@@ -124,3 +125,4 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
if workorders[
|
if workorders[
|
||||||
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||||
workorders[0].state = 'waiting'
|
workorders[0].state = 'waiting'
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
|
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
origin = fields.Char(string='源单据')
|
origin = fields.Char(string='源单据')
|
||||||
is_technology_confirm = fields.Boolean(default=False)
|
is_technology_confirm = fields.Boolean(default=True)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type in ['成品', '坯料']:
|
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)]
|
('product_id', '=', self.production_id.product_id.id)]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
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)
|
productions = self.env['mrp.production'].search(domain)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
if production != self.production_id:
|
if production != self.production_id:
|
||||||
for td_other in production.technology_design_ids:
|
self.env['sf.technology.design'].sudo().unified_procedure_multiple_work_orders(technology_designs,
|
||||||
if td_other.is_auto is False:
|
production)
|
||||||
td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
# for td_other in production.technology_design_ids:
|
||||||
if not td_del or td_del.active is False:
|
# if td_other.is_auto is False:
|
||||||
td_other.write({'active': False})
|
# td_del = technology_designs.filtered(lambda tdo: tdo.route_id.id == td_other.route_id.id)
|
||||||
for td_main in technology_designs:
|
# if not td_del or td_del.active is False:
|
||||||
route_other = production.technology_design_ids.filtered(
|
# td_other.write({'active': False})
|
||||||
lambda td: td.route_id.id == td_main.route_id.id)
|
# for td_main in technology_designs:
|
||||||
if not route_other and td_main.active is True:
|
# route_other = production.technology_design_ids.filtered(
|
||||||
production.write({'technology_design_ids': [(0, 0, {
|
# lambda td: td.route_id.id == td_main.route_id.id)
|
||||||
'route_id': td_main.route_id.id,
|
# if not route_other and td_main.active is True:
|
||||||
'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
# production.write({'technology_design_ids': [(0, 0, {
|
||||||
'sf.production.process.parameter'].search(
|
# 'route_id': td_main.route_id.id,
|
||||||
[('id', '=', td_main.process_parameters_id.id)]).id,
|
# 'process_parameters_id': False if td_main.process_parameters_id is False else self.env[
|
||||||
'sequence': td_main.sequence})]})
|
# 'sf.production.process.parameter'].search(
|
||||||
else:
|
# [('id', '=', td_main.process_parameters_id.id)]).id,
|
||||||
for ro in route_other:
|
# 'sequence': td_main.sequence})]})
|
||||||
domain = [('production_id', '=', self.production_id.id),
|
# else:
|
||||||
('active', 'in', [True, False]),
|
# for ro in route_other:
|
||||||
('route_id', '=', ro.route_id.id)]
|
# domain = [('production_id', '=', self.production_id.id),
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
# ('active', 'in', [True, False]),
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
# ('route_id', '=', ro.route_id.id)]
|
||||||
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
# if ro.route_id.routing_type == '表面工艺':
|
||||||
# display_name = ro.route_id.display_name
|
# domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
domain += [('id', '=', ro.id)]
|
# elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
|
||||||
elif ro.panel is not False:
|
# # display_name = ro.route_id.display_name
|
||||||
domain += [('panel', '=', ro.panel)]
|
# domain += [('id', '=', ro.id)]
|
||||||
td_upd = self.env['sf.technology.design'].sudo().search(domain)
|
# elif ro.panel is not False:
|
||||||
if td_upd:
|
# domain += [('panel', '=', ro.panel)]
|
||||||
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
|
# 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(
|
special_design = self.env['sf.technology.design'].sudo().search(
|
||||||
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
[('routing_tag', '=', 'special'), ('production_id', '=', production.id),
|
||||||
('is_auto', '=', False), ('active', 'in', [True, False])])
|
('is_auto', '=', False), ('active', 'in', [True, False])])
|
||||||
|
|||||||
Reference in New Issue
Block a user