Merge branch 'feature/优化外协采购和出入库单(工艺退回调整)' into develop
This commit is contained in:
@@ -56,6 +56,7 @@ class MrpProduction(models.Model):
|
|||||||
production.deadline_of_delivery = False
|
production.deadline_of_delivery = False
|
||||||
else:
|
else:
|
||||||
production.deadline_of_delivery = False
|
production.deadline_of_delivery = False
|
||||||
|
|
||||||
def _compute_default_delivery_status(self):
|
def _compute_default_delivery_status(self):
|
||||||
try:
|
try:
|
||||||
if self.state == 'cancel':
|
if self.state == 'cancel':
|
||||||
@@ -250,6 +251,7 @@ class MrpProduction(models.Model):
|
|||||||
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
remanufacture_count = fields.Integer("重新制造订单数量", compute='_compute_remanufacture_production_ids')
|
||||||
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
remanufacture_production_id = fields.Many2one('mrp.production', string='')
|
||||||
technology_design_ids = fields.One2many('sf.technology.design', 'production_id', string='工艺设计')
|
technology_design_ids = fields.One2many('sf.technology.design', 'production_id', string='工艺设计')
|
||||||
|
is_adjust = fields.Boolean('是否退回调整', default=False)
|
||||||
|
|
||||||
@api.depends('remanufacture_production_id')
|
@api.depends('remanufacture_production_id')
|
||||||
def _compute_remanufacture_production_ids(self):
|
def _compute_remanufacture_production_ids(self):
|
||||||
@@ -276,7 +278,7 @@ class MrpProduction(models.Model):
|
|||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
|
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
|
||||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
|
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state', 'programming_state')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
for production in self:
|
for production in self:
|
||||||
if not production.state or not production.product_uom_id:
|
if not production.state or not production.product_uom_id:
|
||||||
@@ -309,7 +311,7 @@ class MrpProduction(models.Model):
|
|||||||
# 新添加的状态逻辑
|
# 新添加的状态逻辑
|
||||||
if (
|
if (
|
||||||
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
||||||
if not production.workorder_ids:
|
if not production.workorder_ids or production.is_adjust is True:
|
||||||
production.state = 'technology_to_confirmed'
|
production.state = 'technology_to_confirmed'
|
||||||
else:
|
else:
|
||||||
production.state = 'confirmed'
|
production.state = 'confirmed'
|
||||||
@@ -675,9 +677,12 @@ class MrpProduction(models.Model):
|
|||||||
'operation_id': operation.id,
|
'operation_id': operation.id,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
}]
|
}]
|
||||||
if production.product_id.categ_id.type == '成品':
|
if production.product_id.categ_id.type in ['成品', '坯料']:
|
||||||
# # 根据工序设计生成工单
|
# # 根据工序设计生成工单
|
||||||
for route in production.technology_design_ids:
|
for route in production.technology_design_ids:
|
||||||
|
workorder_has = self.env['mrp.workorder'].search(
|
||||||
|
[('name', '=', route.route_id.name), ('production_id', '=', production.id)])
|
||||||
|
if not workorder_has:
|
||||||
if route.route_id.routing_type not in ['表面工艺']:
|
if route.route_id.routing_type not in ['表面工艺']:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(production, route))
|
self.env['mrp.workorder'].json_workorder_str(production, route))
|
||||||
@@ -688,14 +693,6 @@ class MrpProduction(models.Model):
|
|||||||
self.env[
|
self.env[
|
||||||
'mrp.workorder']._json_workorder_surface_process_str(
|
'mrp.workorder']._json_workorder_surface_process_str(
|
||||||
production, route, product_production_process.seller_ids[0].partner_id.id))
|
production, route, product_production_process.seller_ids[0].partner_id.id))
|
||||||
elif production.product_id.categ_id.type == '坯料':
|
|
||||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
|
||||||
[('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
|
|
||||||
order='sequence asc'
|
|
||||||
)
|
|
||||||
for route_embryo in embryo_routing_workcenter:
|
|
||||||
workorders_values.append(
|
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
|
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
for workorder in production.workorder_ids:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
@@ -717,7 +714,7 @@ class MrpProduction(models.Model):
|
|||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence)
|
||||||
for i, workorder in enumerate(sorted_workorders):
|
for i, workorder in enumerate(sorted_workorders):
|
||||||
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
# 检查当前工作订单和下一个工作订单是否连续,并且供应商相同
|
||||||
if workorder.sequence == 1:
|
if i == 0:
|
||||||
consecutive_workorders.append(workorder)
|
consecutive_workorders.append(workorder)
|
||||||
elif workorder.sequence == sorted_workorders[
|
elif workorder.sequence == sorted_workorders[
|
||||||
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
i - 1].sequence + 1 and workorder.supplier_id.id == sorted_workorders[i - 1].supplier_id.id:
|
||||||
@@ -725,7 +722,7 @@ class MrpProduction(models.Model):
|
|||||||
else:
|
else:
|
||||||
# 处理连续组,如果它不为空
|
# 处理连续组,如果它不为空
|
||||||
if consecutive_workorders:
|
if consecutive_workorders:
|
||||||
# 创建出库拣货单和采购订单
|
# 创建外协出入库单和采购订单
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders, production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
@@ -739,7 +736,7 @@ class MrpProduction(models.Model):
|
|||||||
i - 1].supplier_id.id:
|
i - 1].supplier_id.id:
|
||||||
consecutive_workorders = [workorder]
|
consecutive_workorders = [workorder]
|
||||||
else:
|
else:
|
||||||
# 立即创建出库拣货单和采购订单
|
# 立即创建外协出入库单和采购订单
|
||||||
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
self.env['stock.picking'].create_outcontract_picking(workorder, production)
|
||||||
self.env['purchase.order'].get_purchase_order(workorder, production,
|
self.env['purchase.order'].get_purchase_order(workorder, production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
@@ -817,6 +814,36 @@ class MrpProduction(models.Model):
|
|||||||
self._reset_work_order_sequence1(k)
|
self._reset_work_order_sequence1(k)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# 需对不连续工单对应的采购单和外协出入库单做处理
|
||||||
|
def _reset_subcontract_pick_purchase(self):
|
||||||
|
production_all = self.sorted(lambda x: x.id)
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in
|
||||||
|
groupby(production_all, key=lambda x: x.product_id.id)}
|
||||||
|
for product_id, pd in grouped_product_ids.items():
|
||||||
|
product_id_to_production_names[product_id] = [p.name for p in pd]
|
||||||
|
for item in production_all:
|
||||||
|
production_process = product_id_to_production_names.get(item.product_id.id)
|
||||||
|
workorder_sf = item.workorder_ids.filtered(lambda sf: sf.routing_type == '表面工艺')
|
||||||
|
for i, workorder in enumerate(workorder_sf):
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
elif workorder.sequence != workorder_sf[i - 1].sequence + 1:
|
||||||
|
# workorder.picking_ids.move_ids = False
|
||||||
|
workorder.picking_ids = False
|
||||||
|
purchase_order = self.env['purchase.order'].search(
|
||||||
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
|
('purchase_type', '=', 'consignment')])
|
||||||
|
for line in purchase_order.order_line:
|
||||||
|
server_template = self.env['product.template'].search(
|
||||||
|
[('server_product_process_parameters_id', '=', workorder.surface_technics_parameters_id.id),
|
||||||
|
('detailed_type', '=', 'service')])
|
||||||
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
|
[('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id),
|
||||||
|
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
||||||
|
if purchase_order_line:
|
||||||
|
line.unlink()
|
||||||
|
|
||||||
def _reset_work_order_sequence(self):
|
def _reset_work_order_sequence(self):
|
||||||
"""
|
"""
|
||||||
工单工序排序方法(新)
|
工单工序排序方法(新)
|
||||||
@@ -834,7 +861,8 @@ class MrpProduction(models.Model):
|
|||||||
work_id.sequence = order_id.sequence + 1
|
work_id.sequence = order_id.sequence + 1
|
||||||
break
|
break
|
||||||
# 对该工单之后的工单工序进行加一
|
# 对该工单之后的工单工序进行加一
|
||||||
work_order_ids = rec.workorder_ids.filtered(lambda item: item.sequence >= work_id.sequence)
|
work_order_ids = rec.workorder_ids.filtered(
|
||||||
|
lambda item: item.sequence >= work_id.sequence and item.id != work_id.id)
|
||||||
for work in work_order_ids:
|
for work in work_order_ids:
|
||||||
work.sequence = work.sequence + 1
|
work.sequence = work.sequence + 1
|
||||||
|
|
||||||
@@ -959,10 +987,12 @@ class MrpProduction(models.Model):
|
|||||||
date_planned_end = None
|
date_planned_end = None
|
||||||
date_planned_start = None
|
date_planned_start = None
|
||||||
if self.production_type == '自动化产线加工':
|
if self.production_type == '自动化产线加工':
|
||||||
date_planned_start,date_planned_end,last_time = work.auto_production_process(last_time,count,type_map)
|
date_planned_start, date_planned_end, last_time = work.auto_production_process(last_time, count,
|
||||||
|
type_map)
|
||||||
elif self.production_type == '':
|
elif self.production_type == '':
|
||||||
date_planned_start, date_planned_end, last_time = work.manual_offline_process(last_time, index)
|
date_planned_start, date_planned_end, last_time = work.manual_offline_process(last_time, index)
|
||||||
work.update_work_start_end(date_planned_start, date_planned_end)
|
work.update_work_start_end(date_planned_start, date_planned_end)
|
||||||
|
|
||||||
# def
|
# def
|
||||||
def process_range_time(self):
|
def process_range_time(self):
|
||||||
for production in self:
|
for production in self:
|
||||||
@@ -1104,6 +1134,7 @@ class MrpProduction(models.Model):
|
|||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': {
|
'context': {
|
||||||
'default_production_id': self.id,
|
'default_production_id': self.id,
|
||||||
|
'default_workorder_ids': self.workorder_ids.filtered(lambda wk: wk.state == 'done').ids,
|
||||||
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
||||||
'default_programming_state': cloud_programming['programming_state'],
|
'default_programming_state': cloud_programming['programming_state'],
|
||||||
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
||||||
@@ -1229,6 +1260,7 @@ class MrpProduction(models.Model):
|
|||||||
重新生成制造订单
|
重新生成制造订单
|
||||||
"""
|
"""
|
||||||
if self.is_scrap is True:
|
if self.is_scrap is True:
|
||||||
|
technology_design_values = []
|
||||||
procurement_requests = []
|
procurement_requests = []
|
||||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', self.origin)])
|
sale_order = self.env['sale.order'].sudo().search([('name', '=', self.origin)])
|
||||||
values = self.env['mrp.production'].create_production1_values(self)
|
values = self.env['mrp.production'].create_production1_values(self)
|
||||||
@@ -1259,11 +1291,13 @@ class MrpProduction(models.Model):
|
|||||||
[('origin', '=', self.origin)], order='id desc', limit=1)
|
[('origin', '=', self.origin)], order='id desc', limit=1)
|
||||||
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
|
move = self.env['stock.move'].search([('origin', '=', productions.name)], order='id desc')
|
||||||
for mo in move:
|
for mo in move:
|
||||||
|
domain = []
|
||||||
if mo.procure_method == 'make_to_order' and mo.name != productions.name:
|
if mo.procure_method == 'make_to_order' and mo.name != productions.name:
|
||||||
if mo.name == '/':
|
if mo.name == '/':
|
||||||
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
|
domain = [('barcode', '=', 'WH-PC'), ('sequence_code', '=', 'PC')]
|
||||||
elif mo.name == '拉':
|
elif mo.name == '拉':
|
||||||
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
|
domain = [('barcode', '=', 'WH-INTERNAL'), ('sequence_code', '=', 'INT')]
|
||||||
|
if domain:
|
||||||
picking_type = self.env['stock.picking.type'].search(domain)
|
picking_type = self.env['stock.picking.type'].search(domain)
|
||||||
mo.write({'picking_type_id': picking_type.id})
|
mo.write({'picking_type_id': picking_type.id})
|
||||||
mo._assign_picking()
|
mo._assign_picking()
|
||||||
@@ -1315,10 +1349,72 @@ class MrpProduction(models.Model):
|
|||||||
if purchase_orders.origin.find(productions.name) == -1:
|
if purchase_orders.origin.find(productions.name) == -1:
|
||||||
purchase_orders.origin += ',' + productions.name
|
purchase_orders.origin += ',' + productions.name
|
||||||
if item['is_reprogramming'] is False:
|
if item['is_reprogramming'] is False:
|
||||||
productions._create_workorder(item)
|
|
||||||
productions.programming_state = '已编程'
|
productions.programming_state = '已编程'
|
||||||
else:
|
else:
|
||||||
productions.programming_state = '编程中'
|
productions.programming_state = '编程中'
|
||||||
|
if not technology_design_values:
|
||||||
|
i = 0
|
||||||
|
if self.product_id.categ_id.type == '成品':
|
||||||
|
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||||
|
for k in (self.product_id.model_processing_panel.split(',')):
|
||||||
|
if self.production_type == '自动化产线加工':
|
||||||
|
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||||
|
[('product_model_type_id', '=',
|
||||||
|
self.product_id.product_model_type_id.id)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
product_routing_workcenter = self.env[
|
||||||
|
'sf.manual.product.model.type.routing.sort'].search(
|
||||||
|
[('manual_product_model_type_id', '=',
|
||||||
|
self.product_id.product_model_type_id.id)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
for route in product_routing_workcenter:
|
||||||
|
i += 1
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
||||||
|
elif self.product_id.categ_id.type == '坯料':
|
||||||
|
i = 0
|
||||||
|
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||||
|
[('embryo_model_type_id', '=', self.product_id.embryo_model_type_id.id)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
for route_embryo in embryo_routing_workcenter:
|
||||||
|
i += 1
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i,
|
||||||
|
False))
|
||||||
|
surface_technics_arr = []
|
||||||
|
route_workcenter_arr = []
|
||||||
|
for item in self.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||||
|
if item.route_workcenter_id.surface_technics_id.id:
|
||||||
|
for process_param in self.product_id.model_process_parameters_ids:
|
||||||
|
if item.route_workcenter_id.surface_technics_id == process_param.process_id:
|
||||||
|
surface_technics_arr.append(
|
||||||
|
item.route_workcenter_id.surface_technics_id.id)
|
||||||
|
route_workcenter_arr.append(item.route_workcenter_id.id)
|
||||||
|
if surface_technics_arr:
|
||||||
|
production_process = self.env['sf.production.process'].search(
|
||||||
|
[('id', 'in', surface_technics_arr)],
|
||||||
|
order='sequence asc'
|
||||||
|
)
|
||||||
|
for p in production_process:
|
||||||
|
# logging.info('production_process:%s' % p.name)
|
||||||
|
process_parameter = self.product_id.model_process_parameters_ids.filtered(
|
||||||
|
lambda pm: pm.process_id.id == p.id)
|
||||||
|
if process_parameter:
|
||||||
|
i += 1
|
||||||
|
route_production_process = self.env[
|
||||||
|
'mrp.routing.workcenter'].search(
|
||||||
|
[('surface_technics_id', '=', p.id),
|
||||||
|
('id', 'in', route_workcenter_arr)])
|
||||||
|
technology_design_values.append(
|
||||||
|
self.env['sf.technology.design'].json_technology_design_str(False,
|
||||||
|
route_production_process,
|
||||||
|
i,
|
||||||
|
process_parameter))
|
||||||
|
productions.technology_design_ids = technology_design_values
|
||||||
return productions
|
return productions
|
||||||
|
|
||||||
# 在之前的销售单上重新生成制造订单
|
# 在之前的销售单上重新生成制造订单
|
||||||
|
|||||||
@@ -199,14 +199,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
func(records)
|
func(records)
|
||||||
# 增加页码
|
# 增加页码
|
||||||
page_number += 1
|
page_number += 1
|
||||||
|
|
||||||
def run_compute_construction_period_status(self, records):
|
def run_compute_construction_period_status(self, records):
|
||||||
records._compute_construction_period_status()
|
records._compute_construction_period_status()
|
||||||
|
|
||||||
def _corn_update_construction_period_status(self):
|
def _corn_update_construction_period_status(self):
|
||||||
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected']
|
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected']
|
||||||
# need_list = [
|
# need_list = [
|
||||||
# 'progress',
|
# 'progress',
|
||||||
# 'to be detected']
|
# 'to be detected']
|
||||||
self.get_page_all_records('mrp.workorder',self.run_compute_construction_period_status,[('state', 'in', need_list)],100)
|
self.get_page_all_records('mrp.workorder', self.run_compute_construction_period_status,
|
||||||
|
[('state', 'in', need_list)], 100)
|
||||||
|
|
||||||
def get_hours_diff(self):
|
def get_hours_diff(self):
|
||||||
# 获取当前日期和时间
|
# 获取当前日期和时间
|
||||||
@@ -230,16 +233,16 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
def _compute_surface_technics_picking_ids(self):
|
def _compute_surface_technics_picking_ids(self):
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
if workorder.routing_type == '表面工艺':
|
if workorder.routing_type == '表面工艺':
|
||||||
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel'])]
|
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel']),
|
||||||
|
('partner_id', '!=', False)]
|
||||||
previous_workorder = self.env['mrp.workorder'].search(
|
previous_workorder = self.env['mrp.workorder'].search(
|
||||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||||
('production_id', '=', workorder.production_id.id)])
|
('production_id', '=', workorder.production_id.id)])
|
||||||
if previous_workorder:
|
if previous_workorder:
|
||||||
|
if previous_workorder.supplier_id != workorder.supplier_id:
|
||||||
process_product = self.env['product.template']._get_process_parameters_product(
|
process_product = self.env['product.template']._get_process_parameters_product(
|
||||||
previous_workorder.surface_technics_parameters_id)
|
previous_workorder.surface_technics_parameters_id)
|
||||||
domain += [('partner_id', '=', process_product.partner_id.id)]
|
domain += [('partner_id', '=', process_product.partner_id.id)]
|
||||||
else:
|
|
||||||
domain += [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id.id)]
|
|
||||||
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
picking_ids = self.env['stock.picking'].search(domain, order='id asc')
|
||||||
workorder.surface_technics_picking_count = len(picking_ids)
|
workorder.surface_technics_picking_count = len(picking_ids)
|
||||||
workorder.picking_ids = picking_ids.ids
|
workorder.picking_ids = picking_ids.ids
|
||||||
@@ -782,7 +785,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
||||||
if route.route_id.routing_type in routing_types:
|
if route.route_id.routing_type in routing_types:
|
||||||
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', route.route_id.routing_type)])
|
[('name', '=', oute.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type)])
|
||||||
duration_expected = routing_workcenter.time_cycle
|
duration_expected = routing_workcenter.time_cycle
|
||||||
reserved_duration = routing_workcenter.reserved_duration
|
reserved_duration = routing_workcenter.reserved_duration
|
||||||
else:
|
else:
|
||||||
@@ -792,12 +795,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
'operation_id': False,
|
'operation_id': False,
|
||||||
'name': route.route_id.name,
|
'name': route.name if hasattr(route, 'routing_type') else route.route_id.name,
|
||||||
'processing_panel': route.panel,
|
'processing_panel': False if hasattr(route, 'routing_type') else route.panel,
|
||||||
'sequence': route.sequence,
|
'sequence': route.sequence,
|
||||||
'quality_point_ids': route.route_id.quality_point_ids,
|
'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids,
|
||||||
'routing_type': route.route_id.routing_type,
|
'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type,
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
'workcenter_id': False if hasattr(route, 'routing_type') else self.env[
|
||||||
|
'mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
||||||
route.route_id.routing_type,
|
route.route_id.routing_type,
|
||||||
production.product_id),
|
production.product_id),
|
||||||
# 设定初始化值,避免出现变成bool问题
|
# 设定初始化值,避免出现变成bool问题
|
||||||
@@ -1004,7 +1008,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||||
'production_id.tool_state', 'production_id.schedule_state')
|
'production_id.tool_state', 'production_id.schedule_state', 'sequence')
|
||||||
def _compute_state(self):
|
def _compute_state(self):
|
||||||
# super()._compute_state()
|
# super()._compute_state()
|
||||||
for workorder in self:
|
for workorder in self:
|
||||||
@@ -1015,10 +1019,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if workorder.state == 'pending':
|
if workorder.state == 'pending':
|
||||||
if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||||
if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
||||||
if (workorder.sequence == 1 and not workorder.blocked_by_workorder_ids) or (
|
if ((workorder.sequence == 1 and not workorder.blocked_by_workorder_ids)
|
||||||
workorder.blocked_by_workorder_ids.state in ('done', 'cancel')) or (
|
or (workorder.blocked_by_workorder_ids.state in ('done', 'cancel')
|
||||||
previous_workorder.state in (
|
and workorder.blocked_by_workorder_ids.test_results not in ['报废', '返工'])
|
||||||
'done', 'cancel') and not workorder.blocked_by_workorder_ids):
|
or (previous_workorder.state in ('done', 'cancel')
|
||||||
|
and not workorder.blocked_by_workorder_ids
|
||||||
|
and previous_workorder.test_results not in ['报废', '返工'])
|
||||||
|
):
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
continue
|
continue
|
||||||
if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
||||||
@@ -1045,147 +1052,115 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
|
||||||
cnc_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
|
||||||
('test_results', '=', '返工')])
|
|
||||||
cnc_workorder_pending = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
|
||||||
('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
|
||||||
unclamp_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('production_id', '=', workorder.production_id.id),
|
|
||||||
('sequence', '=', workorder.sequence - 1),
|
|
||||||
('state', 'in', ['done'])])
|
|
||||||
if workorder.state not in ['cancel', 'progress', 'rework']:
|
|
||||||
if workorder.production_id.state == 'rework':
|
|
||||||
if workorder.routing_type == '装夹预调' and workorder.state not in ['done', 'rework',
|
|
||||||
'cancel']:
|
|
||||||
# # 有返工工单
|
|
||||||
# if re_work:
|
|
||||||
# 新工单
|
|
||||||
if workorder.is_rework is False:
|
|
||||||
if workorder.production_id.programming_state == '已编程' and workorder.production_id.is_rework is False:
|
|
||||||
if re_work or cnc_workorder:
|
|
||||||
workorder.state = 'ready'
|
|
||||||
else:
|
|
||||||
if workorder.production_id.is_rework is True:
|
|
||||||
if re_work or cnc_workorder:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
|
|
||||||
elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']:
|
for workorder in self:
|
||||||
pre_workorder = self.env['mrp.workorder'].search(
|
# 如果工单的工序没有进行排序则跳出循环
|
||||||
[('production_id', '=', workorder.production_id.id),
|
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
|
||||||
('processing_panel', '=', workorder.processing_panel),
|
continue
|
||||||
('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
# ===== 对所有按序号排序的非[进行中、完成、返工、取消]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] =====
|
||||||
if pre_workorder:
|
logging.info(workorder.state)
|
||||||
if re_work:
|
work_ids = workorder.production_id.workorder_ids.filtered(
|
||||||
|
lambda wk: wk.state not in ['done', 'rework', 'cancel'])
|
||||||
|
if not work_ids:
|
||||||
|
continue
|
||||||
|
min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence)
|
||||||
|
if workorder.state in ['done', 'rework', 'cancel', 'progress', 'to be detected']:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if workorder != min_sequence_wk:
|
||||||
|
if workorder.state != 'pending':
|
||||||
|
workorder.state = 'pending'
|
||||||
|
continue
|
||||||
|
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||||
|
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
||||||
|
or workorder.production_id.schedule_state != '已排'
|
||||||
|
or workorder.production_id.reservation_state != 'assigned'
|
||||||
|
or workorder.production_id.workorder_ids.filtered(
|
||||||
|
lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']):
|
||||||
|
if workorder.state != 'waiting':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
elif workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']:
|
continue
|
||||||
if cnc_workorder:
|
if workorder.production_id.programming_state == '已编程':
|
||||||
if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
workorder.state = 'ready'
|
||||||
|
elif workorder.state != 'waiting':
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
|
# re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
||||||
|
# cnc_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
||||||
|
# ('test_results', '=', '返工')])
|
||||||
|
# cnc_workorder_pending = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
||||||
|
# unclamp_workorder = self.env['mrp.workorder'].search(
|
||||||
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
|
# ('sequence', '=', workorder.sequence - 1),
|
||||||
|
# ('state', 'in', ['done'])])
|
||||||
|
# if workorder.state not in ['cancel', 'progress', 'rework']:
|
||||||
|
# if workorder.production_id.state == 'rework':
|
||||||
|
# if workorder.routing_type == '装夹预调':
|
||||||
|
# # # 有返工工单
|
||||||
|
# # if re_work:
|
||||||
|
# # 新工单
|
||||||
|
# if workorder.is_rework is False:
|
||||||
|
# if (workorder.production_id.programming_state == '已编程'
|
||||||
|
# and workorder.production_id.is_rework is False):
|
||||||
|
# if re_work or cnc_workorder:
|
||||||
|
# workorder.state = 'ready'
|
||||||
# else:
|
# else:
|
||||||
# if workorder.production_id.is_rework is True:
|
# if workorder.production_id.is_rework is True:
|
||||||
|
# if re_work or cnc_workorder:
|
||||||
# workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
elif workorder.production_id.state == 'progress':
|
#
|
||||||
if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程' and \
|
# elif workorder.routing_type == 'CNC加工':
|
||||||
workorder.is_rework is False and workorder.state not in [
|
# pre_workorder = self.env['mrp.workorder'].search(
|
||||||
'done', 'rework',
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
'cancel']:
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
if workorder.production_id.is_rework is False:
|
# ('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
||||||
if re_work or cnc_workorder or unclamp_workorder:
|
# if pre_workorder:
|
||||||
workorder.state = 'ready'
|
# if re_work:
|
||||||
# if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
# workorder.state = 'waiting'
|
||||||
|
# elif workorder.routing_type == '解除装夹':
|
||||||
|
# if cnc_workorder:
|
||||||
|
# if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
||||||
|
# workorder.state = 'waiting'
|
||||||
|
# # else:
|
||||||
|
# # if workorder.production_id.is_rework is True:
|
||||||
|
# # workorder.state = 'waiting'
|
||||||
|
# elif workorder.production_id.state == 'progress':
|
||||||
|
# if (workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程'
|
||||||
|
# and workorder.is_rework is False and workorder.state not in ['done', 'rework', 'cancel']):
|
||||||
|
# if workorder.production_id.is_rework is False:
|
||||||
|
# if re_work or cnc_workorder or unclamp_workorder:
|
||||||
# workorder.state = 'ready'
|
# workorder.state = 'ready'
|
||||||
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
||||||
if unclamp_workorder:
|
# # workorder.state = 'ready'
|
||||||
if workorder.is_subcontract is False:
|
# if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
||||||
workorder.state = 'ready'
|
# if unclamp_workorder:
|
||||||
else:
|
# if workorder.is_subcontract is False:
|
||||||
production_programming = self.env['mrp.production'].search(
|
|
||||||
[('origin', '=', self.production_id.origin)], order='name asc')
|
|
||||||
production_no_remanufacture = production_programming.filtered(
|
|
||||||
lambda a: a.is_remanufacture is False)
|
|
||||||
production_list = [production.name for production in production_programming]
|
|
||||||
purchase_orders = self.env['purchase.order'].search(
|
|
||||||
[('origin', 'ilike', ','.join(production_list))])
|
|
||||||
for line in purchase_orders.order_line:
|
|
||||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
|
||||||
production_no_remanufacture):
|
|
||||||
if purchase_orders.state == 'purchase':
|
|
||||||
workorder.state = 'ready'
|
|
||||||
else:
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
elif workorder.production_id.state == 'scrap':
|
|
||||||
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
|
||||||
workorder.state = 'waiting'
|
|
||||||
# if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
|
||||||
# workorder_ids = workorder.production_id.workorder_ids
|
|
||||||
# work_bo = True
|
|
||||||
# for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
|
||||||
# if not workorder_ids.filtered(
|
|
||||||
# lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
|
||||||
# and a.processing_panel == wo.processing_panel)):
|
|
||||||
# work_bo = False
|
|
||||||
# break
|
|
||||||
# if (workorder.production_id.programming_state == '已编程' and work_bo
|
|
||||||
# and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
|
||||||
# # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
|
||||||
# if workorder.production_id.tool_state in ['1', '2']:
|
|
||||||
# if workorder.state in ['ready']:
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# continue
|
|
||||||
# elif workorder.state in ['waiting']:
|
|
||||||
# continue
|
|
||||||
# elif workorder.state == 'pending' and workorder == self.search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('routing_type', '=', '装夹预调'),
|
|
||||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
# limit=1,
|
|
||||||
# order="sequence"):
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# continue
|
|
||||||
# elif workorder.production_id.tool_state in ['0']:
|
|
||||||
# if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
|
||||||
# if not workorder_ids.filtered(
|
|
||||||
# lambda a: (a.routing_type not in ['装夹预调'] and
|
|
||||||
# a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
|
||||||
# # 查询工序最小的非完工、非返工的装夹预调工单
|
|
||||||
# work_id = self.search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
# limit=1,
|
|
||||||
# order="sequence")
|
|
||||||
# if work_id.routing_type == '装夹预调':
|
|
||||||
# if workorder == work_id:
|
|
||||||
# if workorder.production_id.reservation_state == 'assigned':
|
|
||||||
# workorder.state = 'ready'
|
# workorder.state = 'ready'
|
||||||
# elif workorder.production_id.reservation_state != 'assigned':
|
# else:
|
||||||
|
# production_programming = self.env['mrp.production'].search(
|
||||||
|
# [('origin', '=', self.production_id.origin)], order='name asc')
|
||||||
|
# production_no_remanufacture = production_programming.filtered(
|
||||||
|
# lambda a: a.is_remanufacture is False)
|
||||||
|
# production_list = [production.name for production in production_programming]
|
||||||
|
# purchase_orders = self.env['purchase.order'].search(
|
||||||
|
# [('origin', 'ilike', ','.join(production_list))])
|
||||||
|
# for line in purchase_orders.order_line:
|
||||||
|
# if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
||||||
|
# production_no_remanufacture):
|
||||||
|
# if purchase_orders.state == 'purchase':
|
||||||
|
# workorder.state = 'ready'
|
||||||
|
# else:
|
||||||
# workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
# continue
|
# elif workorder.production_id.state == 'scrap':
|
||||||
# elif (workorder.name == '装夹预调' and
|
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||||
# workorder.state not in ['rework', 'done', 'cancel']):
|
|
||||||
# if workorder.state != 'pending':
|
|
||||||
# workorder.state = 'pending'
|
|
||||||
# if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
|
||||||
# workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
# continue
|
|
||||||
# if (workorder.production_id.tool_state in ['1', '2']
|
|
||||||
# and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
|
||||||
# and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
|
||||||
# if workorder.state == 'pending' and workorder == self.search(
|
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
|
||||||
# ('routing_type', '=', '装夹预调'),
|
|
||||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
|
||||||
# limit=1,
|
|
||||||
# order="sequence"):
|
|
||||||
# workorder.state = 'waiting'
|
|
||||||
# continue
|
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
@@ -2070,6 +2045,7 @@ class CMMprogram(models.Model):
|
|||||||
date_planned_end = date_planned_start + duration_expected
|
date_planned_end = date_planned_start + duration_expected
|
||||||
last_time = date_planned_end
|
last_time = date_planned_end
|
||||||
return date_planned_start, date_planned_end, last_time
|
return date_planned_start, date_planned_end, last_time
|
||||||
|
|
||||||
def manual_offline_process(self, last_time, is_first):
|
def manual_offline_process(self, last_time, is_first):
|
||||||
date_planned_end = None
|
date_planned_end = None
|
||||||
date_planned_start = None
|
date_planned_start = None
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class sf_technology_design(models.Model):
|
|||||||
|
|
||||||
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,
|
'route_id': route.id if route.routing_type in ['表面工艺'] else route.route_workcenter_id.id,
|
||||||
'panel': k,
|
'panel': k,
|
||||||
'process_parameters_id': False if route.routing_type != '表面工艺' else self.env[
|
'process_parameters_id': False if route.routing_type != '表面工艺' else self.env[
|
||||||
'sf.production.process.parameter'].search(
|
'sf.production.process.parameter'].search(
|
||||||
|
|||||||
@@ -321,7 +321,6 @@ class StockRule(models.Model):
|
|||||||
i = 0
|
i = 0
|
||||||
if production_item.product_id.categ_id.type == '成品':
|
if production_item.product_id.categ_id.type == '成品':
|
||||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||||
|
|
||||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||||
if production_item.production_type == '自动化产线加工':
|
if production_item.production_type == '自动化产线加工':
|
||||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||||
@@ -337,7 +336,7 @@ class StockRule(models.Model):
|
|||||||
i += 1
|
i += 1
|
||||||
technology_design_values.append(
|
technology_design_values.append(
|
||||||
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
||||||
elif production.product_id.categ_id.type == '坯料':
|
elif production_item.product_id.categ_id.type == '坯料':
|
||||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||||
[('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)],
|
[('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)],
|
||||||
order='sequence asc'
|
order='sequence asc'
|
||||||
@@ -378,7 +377,6 @@ class StockRule(models.Model):
|
|||||||
process_parameter))
|
process_parameter))
|
||||||
productions.technology_design_ids = technology_design_values
|
productions.technology_design_ids = technology_design_values
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -661,14 +659,13 @@ class StockPicking(models.Model):
|
|||||||
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
def create_outcontract_picking(self, sorted_workorders_arr, item):
|
||||||
if len(sorted_workorders_arr) > 1:
|
if len(sorted_workorders_arr) > 1:
|
||||||
sorted_workorders_arr = sorted_workorders_arr[0]
|
sorted_workorders_arr = sorted_workorders_arr[0]
|
||||||
stock_picking = self.env['stock.picking'].search(
|
stock_picking = self.env['stock.picking'].search([('origin', '=', item.name), ('name', 'ilike', 'OCOUT')])
|
||||||
[('origin', '=', sorted_workorders_arr.production_id.name), ('name', 'ilike', 'OCOUT')])
|
if not stock_picking or sorted_workorders_arr:
|
||||||
if not stock_picking:
|
|
||||||
for sorted_workorders in sorted_workorders_arr:
|
for sorted_workorders in sorted_workorders_arr:
|
||||||
# pick_ids = []
|
# pick_ids = []
|
||||||
if not sorted_workorders.picking_ids:
|
if not sorted_workorders.picking_ids:
|
||||||
outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
# outcontract_stock_move = self.env['stock.move'].search([('production_id', '=', item.id)])
|
||||||
if not outcontract_stock_move:
|
# if not outcontract_stock_move:
|
||||||
new_picking = True
|
new_picking = True
|
||||||
location_id = self.env['stock.location'].search(
|
location_id = self.env['stock.location'].search(
|
||||||
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
[('barcode', 'ilike', 'VL-SPOC')]).id,
|
||||||
@@ -731,7 +728,7 @@ class ReStockMove(models.Model):
|
|||||||
return {
|
return {
|
||||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||||
'origin': item.name,
|
'origin': item.name,
|
||||||
# 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
||||||
'company_id': self.mapped('company_id').id,
|
'company_id': self.mapped('company_id').id,
|
||||||
'user_id': False,
|
'user_id': False,
|
||||||
'move_type': self.mapped('group_id').move_type or 'direct',
|
'move_type': self.mapped('group_id').move_type or 'direct',
|
||||||
|
|||||||
@@ -84,6 +84,12 @@
|
|||||||
technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done
|
technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//div[@class='d-flex flex-row align-items-start']//span[1]" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_product_forecast_report']" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||||
<!-- <field name="process_state"/> -->
|
<!-- <field name="process_state"/> -->
|
||||||
<field name="state" readonly="1"/>
|
<field name="state" readonly="1"/>
|
||||||
@@ -139,7 +145,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||||
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
|
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
|
||||||
attrs="{'invisible': [('workorder_ids', '!=', [])]}"></button>
|
attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}"></button>
|
||||||
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
|
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
|
||||||
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
|
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
|
||||||
<button name="button_scrap" invisible="1"/>
|
<button name="button_scrap" invisible="1"/>
|
||||||
@@ -353,7 +359,7 @@
|
|||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
|
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
|
||||||
<page string="工艺设计">
|
<page string="工艺设计" attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}">
|
||||||
<field name="technology_design_ids" widget="one2many">
|
<field name="technology_design_ids" widget="one2many">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_re_adjust is True:
|
if self.is_technology_re_adjust is True:
|
||||||
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed')]
|
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
technology_designs = self.env['sf.technology.design'].sudo().search(
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
@@ -42,7 +42,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
'is_auto': td_main.is_auto})]})
|
'is_auto': td_main.is_auto})]})
|
||||||
else:
|
else:
|
||||||
for ro in route_other:
|
for ro in route_other:
|
||||||
domain = [('production_id', '=', self.production_id.id), ('active', 'in', [True, False]),
|
domain = [('production_id', '=', self.production_id.id),
|
||||||
|
('active', 'in', [True, False]),
|
||||||
('route_id', '=', ro.route_id.id)]
|
('route_id', '=', ro.route_id.id)]
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
if ro.route_id.routing_type == '表面工艺':
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
@@ -103,8 +104,17 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
||||||
productions._reset_work_order_sequence()
|
productions._reset_work_order_sequence()
|
||||||
|
if self.production_id.product_id.categ_id.type == '成品':
|
||||||
|
productions._reset_subcontract_pick_purchase()
|
||||||
productions.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = True
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorders = 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)
|
key=lambda a: a.sequence)
|
||||||
|
if workorders[0].state in ['pending']:
|
||||||
|
if workorder[0].production_id.product_id.categ_id.type == '成品':
|
||||||
|
cnc_workorder = self.search(
|
||||||
|
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
|
||||||
|
limit=1, order='id asc')
|
||||||
|
if cnc_workorder.cnc_ids:
|
||||||
workorders[0].state = 'waiting'
|
workorders[0].state = 'waiting'
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
is_technology_confirm = fields.Boolean(default=False)
|
is_technology_confirm = fields.Boolean(default=False)
|
||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_confirm is True:
|
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type == '成品':
|
||||||
domain = [('origin', '=', self.origin)]
|
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||||
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.production_id.technology_design_ids
|
||||||
@@ -56,9 +56,16 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
# lambda td: td.is_auto is False and td.process_parameters_id is not False)
|
# lambda td: td.is_auto is False and td.process_parameters_id is not False)
|
||||||
# # if special:
|
# # if special:
|
||||||
productions._create_workorder(False)
|
productions._create_workorder(False)
|
||||||
|
if self.production_id.product_id.categ_id.type == '成品':
|
||||||
productions.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
|
productions.is_adjust = False
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
if workorder[0].state in ['pending']:
|
if workorder[0].state in ['pending']:
|
||||||
|
if workorder[0].production_id.product_id.categ_id.type == '成品':
|
||||||
|
cnc_workorder = self.search(
|
||||||
|
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
|
||||||
|
limit=1, order='id asc')
|
||||||
|
if cnc_workorder.cnc_ids:
|
||||||
workorder[0].state = 'waiting'
|
workorder[0].state = 'waiting'
|
||||||
|
|||||||
@@ -46,58 +46,5 @@ class ProductionWizard(models.TransientModel):
|
|||||||
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
else:
|
|
||||||
scrap_cnc = self.production_id.workorder_ids.filtered(lambda crw: crw.routing_type == 'CNC加工').cnc_ids
|
|
||||||
scrap_cmm = self.production_id.workorder_ids.filtered(lambda cm: cm.routing_type == 'CNC加工').cmm_ids
|
|
||||||
for item_line in scrap_cnc:
|
|
||||||
vals = {
|
|
||||||
'sequence_number': item_line.sequence_number,
|
|
||||||
'program_name': item_line.program_name,
|
|
||||||
'cutting_tool_name': item_line.cutting_tool_name,
|
|
||||||
'cutting_tool_no': item_line.cutting_tool_no,
|
|
||||||
'processing_type': item_line.processing_type,
|
|
||||||
'margin_x_y': item_line.margin_x_y,
|
|
||||||
'margin_z': item_line.margin_z,
|
|
||||||
'depth_of_processing_z': item_line.depth_of_processing_z,
|
|
||||||
'cutting_tool_extension_length': item_line.cutting_tool_extension_length,
|
|
||||||
'estimated_processing_time': item_line.estimated_processing_time,
|
|
||||||
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
|
||||||
'ftp_path': item_line.program_path,
|
|
||||||
'processing_panel': item_line.workorder_id.processing_panel,
|
|
||||||
'program_create_date': datetime.strftime(item_line.program_create_date,
|
|
||||||
'%Y-%m-%d %H:%M:%S'),
|
|
||||||
'remark': item_line.remark
|
|
||||||
}
|
|
||||||
ret['programming_list'].append(vals)
|
|
||||||
for cmm_line in scrap_cmm:
|
|
||||||
vals = {
|
|
||||||
'sequence_number': cmm_line.sequence_number,
|
|
||||||
'program_name': cmm_line.program_name,
|
|
||||||
'ftp_path': cmm_line.program_path,
|
|
||||||
'processing_panel': item_line.workorder_id.processing_panel,
|
|
||||||
'program_create_date': datetime.strftime(
|
|
||||||
cmm_line.program_create_date,
|
|
||||||
'%Y-%m-%d %H:%M:%S')
|
|
||||||
}
|
|
||||||
ret['programming_list'].append(vals)
|
|
||||||
|
|
||||||
new_production = self.production_id.recreateManufacturing(ret)
|
new_production = self.production_id.recreateManufacturing(ret)
|
||||||
self.production_id.write({'remanufacture_production_id': new_production.id})
|
self.production_id.write({'remanufacture_production_id': new_production.id})
|
||||||
if self.is_reprogramming is False:
|
|
||||||
for panel in new_production.product_id.model_processing_panel.split(','):
|
|
||||||
scrap_cnc_workorder = max(
|
|
||||||
self.production_id.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
scn: scn.processing_panel == panel and scn.routing_type == 'CNC加工'),
|
|
||||||
key=lambda w: w.create_date)
|
|
||||||
scrap_pre_workorder = max(self.production_id.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
pr: pr.processing_panel == panel and pr.routing_type == '装夹预调'),
|
|
||||||
key=lambda w1: w1.create_date)
|
|
||||||
new_cnc_workorder = new_production.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
nc: nc.processing_panel == panel and nc.routing_type == 'CNC加工')
|
|
||||||
new_cnc_workorder.write({'cnc_worksheet': scrap_cnc_workorder.cnc_worksheet})
|
|
||||||
new_pre_workorder = new_production.workorder_ids.filtered(lambda
|
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel)
|
|
||||||
new_pre_workorder.write({'processing_drawing': scrap_pre_workorder.processing_drawing})
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class ReworkWizard(models.TransientModel):
|
|||||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||||
product_id = fields.Many2one('product.product')
|
product_id = fields.Many2one('product.product')
|
||||||
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
production_id = fields.Many2one('mrp.production', string='制造订单号')
|
||||||
|
workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order', string='所有工单',
|
||||||
|
domain="[('production_id', '=', production_id),('state','=','done')]")
|
||||||
rework_reason = fields.Selection(
|
rework_reason = fields.Selection(
|
||||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
||||||
("operate computer", "操机"),
|
("operate computer", "操机"),
|
||||||
@@ -48,55 +50,66 @@ class ReworkWizard(models.TransientModel):
|
|||||||
'test_report': self.workorder_id.detection_report})]})
|
'test_report': self.workorder_id.detection_report})]})
|
||||||
self.workorder_id.button_finish()
|
self.workorder_id.button_finish()
|
||||||
else:
|
else:
|
||||||
if self.production_id.workorder_ids:
|
if self.workorder_ids:
|
||||||
handle_result = self.production_id.detection_result_ids.filtered(
|
# handle_result = self.production_id.detection_result_ids.filtered(
|
||||||
lambda dr: dr.handle_result == '待处理')
|
# lambda dr: dr.handle_result == '待处理')
|
||||||
if handle_result:
|
# if handle_result:
|
||||||
processing_panels_to_handle = set(handle_item.processing_panel for handle_item in handle_result)
|
# processing_panels_to_handle = set(handle_item.processing_panel for handle_item in handle_result)
|
||||||
processing_panels_choice = set(dr_panel.name for dr_panel in self.processing_panel_id)
|
# processing_panels_choice = set(dr_panel.name for dr_panel in self.processing_panel_id)
|
||||||
# 使用集合的差集操作找出那些待处理结果中有但实际可用加工面中没有的加工面
|
# # 使用集合的差集操作找出那些待处理结果中有但实际可用加工面中没有的加工面
|
||||||
processing_panels_missing = processing_panels_to_handle - processing_panels_choice
|
# processing_panels_missing = processing_panels_to_handle - processing_panels_choice
|
||||||
# 存在不一致的加工面
|
# # 存在不一致的加工面
|
||||||
if processing_panels_missing:
|
# if processing_panels_missing:
|
||||||
processing_panels_str = ','.join(processing_panels_missing)
|
# processing_panels_str = ','.join(processing_panels_missing)
|
||||||
raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str)
|
# raise UserError('您还有待处理的检测结果中为%s的加工面未选择' % processing_panels_str)
|
||||||
for panel in self.processing_panel_id:
|
|
||||||
panel_workorder = self.production_id.workorder_ids.filtered(
|
rework_workorder_ids = self.production_id.workorder_ids.filtered(
|
||||||
lambda ap: ap.processing_panel == panel.name and ap.state != 'rework')
|
lambda ap: ap.id in self.workorder_ids.ids)
|
||||||
if panel_workorder:
|
clamp_workorder_ids = None
|
||||||
panel_workorder.write({'state': 'rework'})
|
if rework_workorder_ids:
|
||||||
rework_clamp_workorder = max(panel_workorder.filtered(
|
# 限制
|
||||||
lambda
|
# 1、单独返工CNC工单则不解绑托盘RFID,如单独返工装夹预调工单,则自动解绑托盘RFID;
|
||||||
rp: rp.processing_panel == panel.name and rp.routing_type == '装夹预调' and rp.state in [
|
# 2、返工CNC工单和装夹预调工单则自动解绑RFID
|
||||||
'done', 'rework']))
|
clamp_workorder_ids = rework_workorder_ids.filtered(lambda rp: rp.routing_type == '装夹预调')
|
||||||
# panel_workorder.filtered(
|
if clamp_workorder_ids:
|
||||||
# lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered(
|
for clamp_workorder_id in clamp_workorder_ids:
|
||||||
# lambda wd: wd.status == '待下发').write({'status': '已取消'})
|
self.production_id.workorder_ids.filtered(
|
||||||
# workpiece = self.env['sf.workpiece.delivery'].search([('status', '=', '待下发'), (
|
lambda wk: wk.processing_panel == clamp_workorder_id.processing_panel).write(
|
||||||
# 'workorder_id', '=',
|
{'rfid_code': False})
|
||||||
# panel_workorder.filtered(lambda wd: wd.routing_type == '装夹预调').id)])
|
# 返工工单状态设置为【返工】
|
||||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
rework_workorder_ids.write({'state': 'rework'})
|
||||||
[('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
|
# 查询返工工单对应的工艺设计记录,并调用方法拼接数据,用于创建新的工单
|
||||||
order='sequence asc'
|
|
||||||
)
|
|
||||||
workorders_values = []
|
workorders_values = []
|
||||||
for route in product_routing_workcenter:
|
for work in rework_workorder_ids:
|
||||||
if route.is_repeat is True:
|
route = self.production_id.technology_design_ids.filtered(
|
||||||
|
lambda item: (item.route_id.name in work.name and item.process_parameters_id
|
||||||
|
and item.process_parameters_id == work.surface_technics_parameters_id) or
|
||||||
|
(item.route_id.name == work.name and item.panel
|
||||||
|
and item.panel == work.processing_panel))
|
||||||
|
if route:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(panel.name,
|
self.env['mrp.workorder'].json_workorder_str(self.production_id, route[0]))
|
||||||
self.production_id, route, False))
|
# 创建新工单,并进行返工配置的相关操作
|
||||||
if workorders_values:
|
if workorders_values:
|
||||||
|
# 创建新工单、工序排序、完成检测结果单据
|
||||||
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
||||||
|
new_work_ids = self.production_id.workorder_ids.filtered(lambda kw: kw.sequence == 0)
|
||||||
|
new_pre_workorder_ids = self.production_id.workorder_ids.filtered(
|
||||||
|
lambda kw: kw.routing_type == '装夹预调' and kw.sequence == 0)
|
||||||
self.production_id._reset_work_order_sequence()
|
self.production_id._reset_work_order_sequence()
|
||||||
self.production_id.detection_result_ids.filtered(
|
self.production_id.detection_result_ids.filtered(
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
lambda ap1: ap1.handle_result == '待处理').write({'handle_result': '已处理'})
|
||||||
{'handle_result': '已处理'})
|
panels = [] # 返工的加工面
|
||||||
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
|
# ===================保留装夹测量数据=====================
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
|
if self.is_clamp_measure and clamp_workorder_ids and new_pre_workorder_ids:
|
||||||
'rework', 'done'))
|
for new_pre_workorder in new_pre_workorder_ids:
|
||||||
if new_pre_workorder and rework_clamp_workorder and self.is_clamp_measure is True:
|
if new_pre_workorder.processing_panel and new_pre_workorder.processing_panel not in panels:
|
||||||
|
panels.append(new_pre_workorder.processing_panel)
|
||||||
|
for rework_clamp_workorder in clamp_workorder_ids:
|
||||||
|
if new_pre_workorder.sequence == rework_clamp_workorder.sequence + 1:
|
||||||
new_pre_workorder.write(
|
new_pre_workorder.write(
|
||||||
{'X1_axis': rework_clamp_workorder.X1_axis, 'Y1_axis': rework_clamp_workorder.Y1_axis
|
{'X1_axis': rework_clamp_workorder.X1_axis,
|
||||||
|
'Y1_axis': rework_clamp_workorder.Y1_axis
|
||||||
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
||||||
'X2_axis': rework_clamp_workorder.X2_axis
|
'X2_axis': rework_clamp_workorder.X2_axis
|
||||||
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
||||||
@@ -128,20 +141,25 @@ class ReworkWizard(models.TransientModel):
|
|||||||
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
||||||
'material_center_point': rework_clamp_workorder.material_center_point
|
'material_center_point': rework_clamp_workorder.material_center_point
|
||||||
})
|
})
|
||||||
|
break
|
||||||
|
# =====================不申请重新编程====================
|
||||||
if self.is_reprogramming is False:
|
if self.is_reprogramming is False:
|
||||||
if self.programming_state in ['已编程', '已下发']:
|
if self.programming_state in ['已编程', '已下发']:
|
||||||
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
||||||
self.production_id.get_new_program(panel.name)
|
for panel_name in panels:
|
||||||
|
self.production_id.get_new_program(panel_name)
|
||||||
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
||||||
|
# ============= 处理CNC加工加工工单的 CNC程序和cmm程序 信息=============
|
||||||
|
for cnc_work in new_work_ids.filtered(lambda wk: wk.name == 'CNC加工'):
|
||||||
ret = {'programming_list': []}
|
ret = {'programming_list': []}
|
||||||
cnc_rework = max(
|
old_cnc_rework = max(self.production_id.workorder_ids.filtered(
|
||||||
self.production_id.workorder_ids.filtered(
|
lambda crw: crw.processing_panel == cnc_work.processing_panel
|
||||||
lambda
|
and crw.state == 'rework' and crw.routing_type == 'CNC加工'),
|
||||||
crw: crw.processing_panel == panel.name and crw.state == 'rework' and crw.routing_type == 'CNC加工'),
|
|
||||||
key=lambda w: w.create_date
|
key=lambda w: w.create_date
|
||||||
)
|
)
|
||||||
if cnc_rework.cnc_ids:
|
# 获取当前工单的CNC程序和cmm程序
|
||||||
for item_line in cnc_rework.cnc_ids:
|
if old_cnc_rework.cnc_ids:
|
||||||
|
for item_line in old_cnc_rework.cnc_ids:
|
||||||
vals = {
|
vals = {
|
||||||
'sequence_number': item_line.sequence_number,
|
'sequence_number': item_line.sequence_number,
|
||||||
'program_name': item_line.program_name,
|
'program_name': item_line.program_name,
|
||||||
@@ -156,46 +174,50 @@ class ReworkWizard(models.TransientModel):
|
|||||||
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
||||||
'program_path': item_line.program_path,
|
'program_path': item_line.program_path,
|
||||||
'ftp_path': item_line.program_path,
|
'ftp_path': item_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'processing_panel': cnc_work.processing_panel,
|
||||||
'program_create_date': datetime.strftime(item_line.program_create_date,
|
'program_create_date': datetime.strftime(item_line.program_create_date,
|
||||||
'%Y-%m-%d %H:%M:%S'),
|
'%Y-%m-%d %H:%M:%S'),
|
||||||
'remark': item_line.remark
|
'remark': item_line.remark
|
||||||
}
|
}
|
||||||
ret['programming_list'].append(vals)
|
ret['programming_list'].append(vals)
|
||||||
for cmm_line in cnc_rework.cmm_ids:
|
for cmm_line in old_cnc_rework.cmm_ids:
|
||||||
vals = {
|
vals = {
|
||||||
'sequence_number': cmm_line.sequence_number,
|
'sequence_number': cmm_line.sequence_number,
|
||||||
'program_name': cmm_line.program_name,
|
'program_name': cmm_line.program_name,
|
||||||
'program_path': cmm_line.program_path,
|
'program_path': cmm_line.program_path,
|
||||||
'ftp_path': cmm_line.program_path,
|
'ftp_path': cmm_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'processing_panel': cnc_work.processing_panel,
|
||||||
'program_create_date': datetime.strftime(
|
'program_create_date': datetime.strftime(
|
||||||
cmm_line.program_create_date,
|
cmm_line.program_create_date,
|
||||||
'%Y-%m-%d %H:%M:%S')
|
'%Y-%m-%d %H:%M:%S')
|
||||||
}
|
}
|
||||||
ret['programming_list'].append(vals)
|
ret['programming_list'].append(vals)
|
||||||
|
# 获取新的
|
||||||
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.state not in (
|
lambda ap1: ap1.processing_panel == cnc_work.processing_panel
|
||||||
'rework', 'done') and ap1.routing_type == 'CNC加工')
|
and ap1.state not in (
|
||||||
|
'rework', 'done') and ap1.routing_type == 'CNC加工'
|
||||||
|
)
|
||||||
if not new_cnc_workorder.cnc_ids:
|
if not new_cnc_workorder.cnc_ids:
|
||||||
new_cnc_workorder.write({
|
new_cnc_workorder.write({
|
||||||
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel.name,
|
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(
|
||||||
ret),
|
cnc_work.processing_panel, ret),
|
||||||
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name,
|
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(
|
||||||
ret),
|
cnc_work.processing_panel, ret),
|
||||||
'cnc_worksheet': cnc_rework.cnc_worksheet})
|
'cnc_worksheet': old_cnc_rework.cnc_worksheet})
|
||||||
|
# ========== 处理装夹预调 【装夹图纸】 数据 ================
|
||||||
if new_pre_workorder:
|
for new_pre_work in new_pre_workorder_ids:
|
||||||
pre_rework = max(self.production_id.workorder_ids.filtered(
|
pre_rework = max(self.production_id.workorder_ids.filtered(
|
||||||
lambda pr: pr.processing_panel == panel.name and pr.state in (
|
lambda pr: (pr.processing_panel == new_pre_work.processing_panel
|
||||||
'rework') and pr.routing_type == '装夹预调'),
|
and pr.state in ['rework'] and pr.routing_type == '装夹预调')),
|
||||||
key=lambda w1: w1.create_date)
|
key=lambda w1: w1.create_date)
|
||||||
new_pre_workorder.write(
|
new_pre_work.write(
|
||||||
{'processing_drawing': pre_rework.processing_drawing})
|
{'processing_drawing': pre_rework.processing_drawing})
|
||||||
self.production_id.write({'state': 'progress', 'is_rework': False})
|
self.production_id.write({'state': 'progress', 'is_rework': False})
|
||||||
elif self.programming_state in ['待编程', '编程中']:
|
elif self.programming_state in ['待编程', '编程中']:
|
||||||
self.production_id.write(
|
self.production_id.write(
|
||||||
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
||||||
|
# ==================申请重新编程=======================
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
self.production_id.write(
|
self.production_id.write(
|
||||||
|
|||||||
@@ -11,10 +11,14 @@
|
|||||||
<field name="product_id" invisible="True"/>
|
<field name="product_id" invisible="True"/>
|
||||||
<field name="tool_state" invisible="True"/>
|
<field name="tool_state" invisible="True"/>
|
||||||
<field name="routing_type" invisible="True"/>
|
<field name="routing_type" invisible="True"/>
|
||||||
|
<field name="processing_panel_id" invisible="1"/>
|
||||||
<group>
|
<group>
|
||||||
<field name="processing_panel_id" options="{'no_create': True}"
|
<field name="workorder_ids" string="工序" attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
||||||
attrs='{"invisible": [("routing_type","=","装夹预调")]}' widget="many2many_tags"/>
|
<tree create="0" editable='bottom' delete="0">
|
||||||
|
<field name="processing_panel" readonly="1"/>
|
||||||
|
<field name="name" readonly="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<div attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
<div attrs='{"invisible": [("routing_type","=","装夹预调")]}'>
|
||||||
<span style='font-weight:bold;'>保留装夹测量数据
|
<span style='font-weight:bold;'>保留装夹测量数据
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
|||||||
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
||||||
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
||||||
else:
|
else:
|
||||||
domain += [('state', '=', 'confirmed')]
|
domain += [('state', 'in', ['confirmed', 'pending_cam'])]
|
||||||
productions = request.env['mrp.production'].with_user(
|
productions = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search(domain)
|
request.env.ref("base.user_admin")).search(domain)
|
||||||
if productions:
|
if productions:
|
||||||
|
|||||||
@@ -264,11 +264,10 @@ class RePurchaseOrder(models.Model):
|
|||||||
'product_uom': server_template.uom_id.id
|
'product_uom': server_template.uom_id.id
|
||||||
}))
|
}))
|
||||||
else:
|
else:
|
||||||
for item in purchase_order_line:
|
|
||||||
if production.name in production_process:
|
if production.name in production_process:
|
||||||
purchase_order = self.env['purchase.order'].search(
|
purchase_order = self.env['purchase.order'].search(
|
||||||
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
('id', '=', item.order_id.id)])
|
('purchase_type', '=', 'consignment')])
|
||||||
if not purchase_order:
|
if not purchase_order:
|
||||||
server_product_process.append((0, 0, {
|
server_product_process.append((0, 0, {
|
||||||
'product_id': server_template.product_variant_id.id,
|
'product_id': server_template.product_variant_id.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user