Merge branch 'feature/返工优化' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化外协采购和出入库单(工艺退回调整)
This commit is contained in:
@@ -869,7 +869,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
|
||||||
|
|
||||||
@@ -1139,6 +1140,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
|
||||||
|
|||||||
@@ -1005,7 +1005,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:
|
||||||
@@ -1046,147 +1046,107 @@ 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),
|
break
|
||||||
('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
# ===== 对所有按序号排序的非[进行中、完成、返工、取消]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] =====
|
||||||
if pre_workorder:
|
min_sequence_wk = min(workorder.production_id.workorder_ids.filtered(
|
||||||
if re_work:
|
lambda wk: wk.state not in ['done', 'rework', 'cancel']),
|
||||||
workorder.state = 'waiting'
|
key=lambda wk: wk.sequence)
|
||||||
elif workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']:
|
if workorder.state in ['done', 'rework', 'cancel', 'progress']:
|
||||||
if cnc_workorder:
|
continue
|
||||||
if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
else:
|
||||||
workorder.state = 'waiting'
|
if workorder != min_sequence_wk:
|
||||||
# else:
|
if workorder.state != 'pending':
|
||||||
# if workorder.production_id.is_rework is True:
|
workorder.state = 'pending'
|
||||||
# workorder.state = 'waiting'
|
continue
|
||||||
elif workorder.production_id.state == 'progress':
|
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||||
if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程' and \
|
if workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework':
|
||||||
workorder.is_rework is False and workorder.state not in [
|
workorder.state = 'waiting'
|
||||||
'done', 'rework',
|
continue
|
||||||
'cancel']:
|
if workorder.production_id.programming_state == '已编程':
|
||||||
if workorder.production_id.is_rework is False:
|
workorder.state = 'ready'
|
||||||
if re_work or cnc_workorder or unclamp_workorder:
|
else:
|
||||||
workorder.state = 'ready'
|
workorder.state = 'waiting'
|
||||||
# if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
# re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
||||||
# workorder.state = 'ready'
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
# ('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
||||||
if unclamp_workorder:
|
# cnc_workorder = self.env['mrp.workorder'].search(
|
||||||
if workorder.is_subcontract is False:
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
workorder.state = 'ready'
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
else:
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
||||||
production_programming = self.env['mrp.production'].search(
|
# ('test_results', '=', '返工')])
|
||||||
[('origin', '=', self.production_id.origin)], order='name asc')
|
# cnc_workorder_pending = self.env['mrp.workorder'].search(
|
||||||
production_no_remanufacture = production_programming.filtered(
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
lambda a: a.is_remanufacture is False)
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
production_list = [production.name for production in production_programming]
|
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
||||||
purchase_orders = self.env['purchase.order'].search(
|
# unclamp_workorder = self.env['mrp.workorder'].search(
|
||||||
[('origin', 'ilike', ','.join(production_list))])
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
for line in purchase_orders.order_line:
|
# ('sequence', '=', workorder.sequence - 1),
|
||||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
# ('state', 'in', ['done'])])
|
||||||
production_no_remanufacture):
|
# if workorder.state not in ['cancel', 'progress', 'rework']:
|
||||||
if purchase_orders.state == 'purchase':
|
# if workorder.production_id.state == 'rework':
|
||||||
workorder.state = 'ready'
|
# if workorder.routing_type == '装夹预调':
|
||||||
else:
|
# # # 有返工工单
|
||||||
workorder.state = 'waiting'
|
# # if re_work:
|
||||||
elif workorder.production_id.state == 'scrap':
|
# # 新工单
|
||||||
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
# if workorder.is_rework is False:
|
||||||
workorder.state = 'waiting'
|
# if (workorder.production_id.programming_state == '已编程'
|
||||||
# if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
# and workorder.production_id.is_rework is False):
|
||||||
# workorder_ids = workorder.production_id.workorder_ids
|
# if re_work or cnc_workorder:
|
||||||
# work_bo = True
|
# workorder.state = 'ready'
|
||||||
# for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
# else:
|
||||||
# if not workorder_ids.filtered(
|
# if workorder.production_id.is_rework is True:
|
||||||
# lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
# if re_work or cnc_workorder:
|
||||||
# and a.processing_panel == wo.processing_panel)):
|
# workorder.state = 'waiting'
|
||||||
# work_bo = False
|
#
|
||||||
# break
|
# elif workorder.routing_type == 'CNC加工':
|
||||||
# if (workorder.production_id.programming_state == '已编程' and work_bo
|
# pre_workorder = self.env['mrp.workorder'].search(
|
||||||
# and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
# [('production_id', '=', workorder.production_id.id),
|
||||||
# # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
# ('processing_panel', '=', workorder.processing_panel),
|
||||||
# if workorder.production_id.tool_state in ['1', '2']:
|
# ('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
||||||
# if workorder.state in ['ready']:
|
# if pre_workorder:
|
||||||
# workorder.state = 'waiting'
|
# if re_work:
|
||||||
# continue
|
# workorder.state = 'waiting'
|
||||||
# elif workorder.state in ['waiting']:
|
# elif workorder.routing_type == '解除装夹':
|
||||||
# continue
|
# if cnc_workorder:
|
||||||
# elif workorder.state == 'pending' and workorder == self.search(
|
# if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
# workorder.state = 'waiting'
|
||||||
# ('routing_type', '=', '装夹预调'),
|
# # else:
|
||||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
# # if workorder.production_id.is_rework is True:
|
||||||
# limit=1,
|
# # workorder.state = 'waiting'
|
||||||
# order="sequence"):
|
# elif workorder.production_id.state == 'progress':
|
||||||
# workorder.state = 'waiting'
|
# if (workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程'
|
||||||
# continue
|
# and workorder.is_rework is False and workorder.state not in ['done', 'rework', 'cancel']):
|
||||||
# elif workorder.production_id.tool_state in ['0']:
|
# if workorder.production_id.is_rework is False:
|
||||||
# if workorder_ids.filtered(lambda a: a.state == 'rework'):
|
# if re_work or cnc_workorder or unclamp_workorder:
|
||||||
# if not workorder_ids.filtered(
|
# workorder.state = 'ready'
|
||||||
# lambda a: (a.routing_type not in ['装夹预调'] and
|
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
||||||
# a.state not in ['pending', 'done', 'rework', 'cancel'])):
|
# # workorder.state = 'ready'
|
||||||
# # 查询工序最小的非完工、非返工的装夹预调工单
|
# if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
||||||
# work_id = self.search(
|
# if unclamp_workorder:
|
||||||
# [('production_id', '=', workorder.production_id.id),
|
# if workorder.is_subcontract is False:
|
||||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
# workorder.state = 'ready'
|
||||||
# limit=1,
|
# else:
|
||||||
# order="sequence")
|
# production_programming = self.env['mrp.production'].search(
|
||||||
# if work_id.routing_type == '装夹预调':
|
# [('origin', '=', self.production_id.origin)], order='name asc')
|
||||||
# if workorder == work_id:
|
# production_no_remanufacture = production_programming.filtered(
|
||||||
# if workorder.production_id.reservation_state == 'assigned':
|
# lambda a: a.is_remanufacture is False)
|
||||||
# workorder.state = 'ready'
|
# production_list = [production.name for production in production_programming]
|
||||||
# elif workorder.production_id.reservation_state != 'assigned':
|
# purchase_orders = self.env['purchase.order'].search(
|
||||||
# workorder.state = 'waiting'
|
# [('origin', 'ilike', ','.join(production_list))])
|
||||||
# continue
|
# for line in purchase_orders.order_line:
|
||||||
# elif (workorder.name == '装夹预调' and
|
# if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id and line.product_qty == len(
|
||||||
# workorder.state not in ['rework', 'done', 'cancel']):
|
# production_no_remanufacture):
|
||||||
# if workorder.state != 'pending':
|
# if purchase_orders.state == 'purchase':
|
||||||
# workorder.state = 'pending'
|
# workorder.state = 'ready'
|
||||||
# if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
# else:
|
||||||
# workorder.state = 'waiting'
|
# workorder.state = 'waiting'
|
||||||
# continue
|
# elif workorder.production_id.state == 'scrap':
|
||||||
# if (workorder.production_id.tool_state in ['1', '2']
|
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||||
# and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
# workorder.state = 'waiting'
|
||||||
# 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):
|
||||||
|
|||||||
@@ -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,100 +50,116 @@ 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 = []
|
||||||
)
|
for work in rework_workorder_ids:
|
||||||
workorders_values = []
|
route = self.production_id.technology_design_ids.filtered(
|
||||||
for route in product_routing_workcenter:
|
lambda item: (item.route_id.name in work.name and item.process_parameters_id
|
||||||
if route.is_repeat is True:
|
and item.process_parameters_id == work.surface_technics_parameters_id) or
|
||||||
workorders_values.append(
|
(item.route_id.name == work.name and item.panel
|
||||||
self.env['mrp.workorder'].json_workorder_str(panel.name,
|
and item.panel == work.processing_panel))
|
||||||
self.production_id, route, False))
|
if route:
|
||||||
if workorders_values:
|
workorders_values.append(
|
||||||
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
self.env['mrp.workorder'].json_workorder_str(self.production_id, route[0]))
|
||||||
self.production_id._reset_work_order_sequence()
|
# 创建新工单,并进行返工配置的相关操作
|
||||||
self.production_id.detection_result_ids.filtered(
|
if workorders_values:
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
# 创建新工单、工序排序、完成检测结果单据
|
||||||
{'handle_result': '已处理'})
|
self.production_id.write({'workorder_ids': workorders_values, 'is_rework': True})
|
||||||
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
|
new_work_ids = self.production_id.workorder_ids.filtered(lambda kw: kw.sequence == 0)
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
|
new_pre_workorder_ids = self.production_id.workorder_ids.filtered(
|
||||||
'rework', 'done'))
|
lambda kw: kw.routing_type == '装夹预调' and kw.sequence == 0)
|
||||||
if new_pre_workorder and rework_clamp_workorder and self.is_clamp_measure is True:
|
self.production_id._reset_work_order_sequence()
|
||||||
new_pre_workorder.write(
|
self.production_id.detection_result_ids.filtered(
|
||||||
{'X1_axis': rework_clamp_workorder.X1_axis, 'Y1_axis': rework_clamp_workorder.Y1_axis
|
lambda ap1: ap1.handle_result == '待处理').write({'handle_result': '已处理'})
|
||||||
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
panels = [] # 返工的加工面
|
||||||
'X2_axis': rework_clamp_workorder.X2_axis
|
# ===================保留装夹测量数据=====================
|
||||||
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
if self.is_clamp_measure and clamp_workorder_ids and new_pre_workorder_ids:
|
||||||
'Z2_axis': rework_clamp_workorder.Z2_axis
|
for new_pre_workorder in new_pre_workorder_ids:
|
||||||
, 'X3_axis': rework_clamp_workorder.X3_axis,
|
if new_pre_workorder.processing_panel and new_pre_workorder.processing_panel not in panels:
|
||||||
'Y3_axis': rework_clamp_workorder.Y3_axis
|
panels.append(new_pre_workorder.processing_panel)
|
||||||
, 'Z3_axis': rework_clamp_workorder.Z3_axis,
|
for rework_clamp_workorder in clamp_workorder_ids:
|
||||||
'X4_axis': rework_clamp_workorder.X4_axis
|
if new_pre_workorder.sequence == rework_clamp_workorder.sequence + 1:
|
||||||
, 'Y4_axis': rework_clamp_workorder.Y4_axis,
|
new_pre_workorder.write(
|
||||||
'Z4_axis': rework_clamp_workorder.Z4_axis
|
{'X1_axis': rework_clamp_workorder.X1_axis,
|
||||||
, 'X5_axis': rework_clamp_workorder.X5_axis,
|
'Y1_axis': rework_clamp_workorder.Y1_axis
|
||||||
'Y5_axis': rework_clamp_workorder.Y5_axis
|
, 'Z1_axis': rework_clamp_workorder.Z1_axis,
|
||||||
, 'Z5_axis': rework_clamp_workorder.Z5_axis,
|
'X2_axis': rework_clamp_workorder.X2_axis
|
||||||
'X6_axis': rework_clamp_workorder.X6_axis
|
, 'Y2_axis': rework_clamp_workorder.Y2_axis,
|
||||||
, 'Y6_axis': rework_clamp_workorder.Y6_axis,
|
'Z2_axis': rework_clamp_workorder.Z2_axis
|
||||||
'Z6_axis': rework_clamp_workorder.Z6_axis
|
, 'X3_axis': rework_clamp_workorder.X3_axis,
|
||||||
, 'X7_axis': rework_clamp_workorder.X7_axis,
|
'Y3_axis': rework_clamp_workorder.Y3_axis
|
||||||
'Y7_axis': rework_clamp_workorder.Y7_axis
|
, 'Z3_axis': rework_clamp_workorder.Z3_axis,
|
||||||
, 'Z7_axis': rework_clamp_workorder.Z7_axis,
|
'X4_axis': rework_clamp_workorder.X4_axis
|
||||||
'X8_axis': rework_clamp_workorder.X8_axis
|
, 'Y4_axis': rework_clamp_workorder.Y4_axis,
|
||||||
, 'Y8_axis': rework_clamp_workorder.Y8_axis,
|
'Z4_axis': rework_clamp_workorder.Z4_axis
|
||||||
'Z8_axis': rework_clamp_workorder.Z8_axis
|
, 'X5_axis': rework_clamp_workorder.X5_axis,
|
||||||
, 'X9_axis': rework_clamp_workorder.X9_axis,
|
'Y5_axis': rework_clamp_workorder.Y5_axis
|
||||||
'Y9_axis': rework_clamp_workorder.Y9_axis
|
, 'Z5_axis': rework_clamp_workorder.Z5_axis,
|
||||||
, 'Z9_axis': rework_clamp_workorder.Z9_axis,
|
'X6_axis': rework_clamp_workorder.X6_axis
|
||||||
'X10_axis': rework_clamp_workorder.X10_axis
|
, 'Y6_axis': rework_clamp_workorder.Y6_axis,
|
||||||
, 'Y10_axis': rework_clamp_workorder.Y10_axis,
|
'Z6_axis': rework_clamp_workorder.Z6_axis
|
||||||
'Z10_axis': rework_clamp_workorder.Z10_axis
|
, 'X7_axis': rework_clamp_workorder.X7_axis,
|
||||||
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
'Y7_axis': rework_clamp_workorder.Y7_axis
|
||||||
'material_center_point': rework_clamp_workorder.material_center_point
|
, 'Z7_axis': rework_clamp_workorder.Z7_axis,
|
||||||
})
|
'X8_axis': rework_clamp_workorder.X8_axis
|
||||||
if self.is_reprogramming is False:
|
, 'Y8_axis': rework_clamp_workorder.Y8_axis,
|
||||||
if self.programming_state in ['已编程', '已下发']:
|
'Z8_axis': rework_clamp_workorder.Z8_axis
|
||||||
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
, 'X9_axis': rework_clamp_workorder.X9_axis,
|
||||||
self.production_id.get_new_program(panel.name)
|
'Y9_axis': rework_clamp_workorder.Y9_axis
|
||||||
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
, 'Z9_axis': rework_clamp_workorder.Z9_axis,
|
||||||
|
'X10_axis': rework_clamp_workorder.X10_axis
|
||||||
|
, 'Y10_axis': rework_clamp_workorder.Y10_axis,
|
||||||
|
'Z10_axis': rework_clamp_workorder.Z10_axis
|
||||||
|
, 'X_deviation_angle': rework_clamp_workorder.X_deviation_angle,
|
||||||
|
'material_center_point': rework_clamp_workorder.material_center_point
|
||||||
|
})
|
||||||
|
break
|
||||||
|
# =====================不申请重新编程====================
|
||||||
|
if self.is_reprogramming is False:
|
||||||
|
if self.programming_state in ['已编程', '已下发']:
|
||||||
|
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
||||||
|
for panel_name in panels:
|
||||||
|
self.production_id.get_new_program(panel_name)
|
||||||
|
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;'>保留装夹测量数据
|
||||||
|
|||||||
Reference in New Issue
Block a user