cnc工单没有回退按钮问题
This commit is contained in:
@@ -17,7 +17,6 @@ from odoo.exceptions import UserError, ValidationError
|
|||||||
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ResMrpWorkOrder(models.Model):
|
class ResMrpWorkOrder(models.Model):
|
||||||
_inherit = 'mrp.workorder'
|
_inherit = 'mrp.workorder'
|
||||||
_order = 'sequence asc'
|
_order = 'sequence asc'
|
||||||
@@ -91,7 +90,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
('state', '!=', 'cancel')
|
('state', '!=', 'cancel')
|
||||||
])
|
])
|
||||||
finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None)
|
finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None)
|
||||||
if not finish_move and not cur_workorder.is_subcontract and not cur_workorder.name =='解除装夹':
|
if not finish_move and not cur_workorder.is_subcontract and not cur_workorder.name == '解除装夹':
|
||||||
record.back_button_display = True
|
record.back_button_display = True
|
||||||
else:
|
else:
|
||||||
record.back_button_display = any(
|
record.back_button_display = any(
|
||||||
@@ -107,12 +106,14 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
next_workorder = sorted_workorders[position + 1]
|
next_workorder = sorted_workorders[position + 1]
|
||||||
next_state = next_workorder.state
|
next_state = next_workorder.state
|
||||||
if ((next_state == 'ready' and not next_workorder.is_subcontract and not next_workorder.name =='解除装夹') or (next_workorder.state == 'pending' and next_workorder.is_subcontract and not next_workorder.name =='解除装夹')) and cur_workorder.state == 'done':
|
if (next_state == 'ready' or (
|
||||||
|
next_workorder.state == 'pending' and next_workorder.is_subcontract)) and cur_workorder.state == 'done':
|
||||||
record.back_button_display = True
|
record.back_button_display = True
|
||||||
else:
|
else:
|
||||||
record.back_button_display = False
|
record.back_button_display = False
|
||||||
if cur_workorder.is_subcontract or cur_workorder.name =='解除装夹':
|
if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹':
|
||||||
record.back_button_display = False
|
record.back_button_display = False
|
||||||
|
|
||||||
date_planned_start = fields.Datetime(tracking=True)
|
date_planned_start = fields.Datetime(tracking=True)
|
||||||
|
|
||||||
@api.depends('processing_panel')
|
@api.depends('processing_panel')
|
||||||
@@ -149,10 +150,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
])
|
])
|
||||||
finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None) or []
|
finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None) or []
|
||||||
if any(
|
if any(
|
||||||
finish_move.move_dest_ids.ids in move.ids
|
finish_move.move_dest_ids.ids in move.ids
|
||||||
for picking in finished_product_area
|
for picking in finished_product_area
|
||||||
for move in picking.move_ids
|
for move in picking.move_ids
|
||||||
):
|
):
|
||||||
raise UserError('已入库,无法回退')
|
raise UserError('已入库,无法回退')
|
||||||
else:
|
else:
|
||||||
moves = self.env['stock.move'].search([
|
moves = self.env['stock.move'].search([
|
||||||
@@ -576,6 +577,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
|
||||||
detailed_reason = fields.Text('详细原因')
|
detailed_reason = fields.Text('详细原因')
|
||||||
is_rework = fields.Boolean(string='是否返工', default=False)
|
is_rework = fields.Boolean(string='是否返工', default=False)
|
||||||
|
|
||||||
# rework_flag = fields.Boolean(string='返工标志', compute='_compute_rework_flag')
|
# rework_flag = fields.Boolean(string='返工标志', compute='_compute_rework_flag')
|
||||||
#
|
#
|
||||||
# @api.depends('state', 'production_line_state')
|
# @api.depends('state', 'production_line_state')
|
||||||
@@ -1265,6 +1267,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
mo.get_move_line(workorder.production_id, workorder))
|
mo.get_move_line(workorder.production_id, workorder))
|
||||||
else:
|
else:
|
||||||
workorder.state = 'waiting'
|
workorder.state = 'waiting'
|
||||||
|
|
||||||
# 重写工单开始按钮方法
|
# 重写工单开始按钮方法
|
||||||
def button_start(self):
|
def button_start(self):
|
||||||
# 判断工单状态是否为等待组件
|
# 判断工单状态是否为等待组件
|
||||||
@@ -1431,7 +1434,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'detailed_reason': record.detailed_reason,
|
'detailed_reason': record.detailed_reason,
|
||||||
'processing_panel': record.processing_panel,
|
'processing_panel': record.processing_panel,
|
||||||
'routing_type': record.routing_type,
|
'routing_type': record.routing_type,
|
||||||
'handle_result': '待处理' if record.test_results in ['返工', '报废'] or record.is_rework is True else '',
|
'handle_result': '待处理' if record.test_results in ['返工',
|
||||||
|
'报废'] or record.is_rework is True else '',
|
||||||
'test_results': record.test_results,
|
'test_results': record.test_results,
|
||||||
'test_report': record.detection_report})],
|
'test_report': record.detection_report})],
|
||||||
'is_scrap': True if record.test_results == '报废' else False
|
'is_scrap': True if record.test_results == '报废' else False
|
||||||
@@ -1448,7 +1452,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
raise UserError('请先完成该工单的工艺外协再进行操作')
|
raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||||
# 表面工艺外协,最后一张工单
|
# 表面工艺外协,最后一张工单
|
||||||
workorders = self.production_id.workorder_ids
|
workorders = self.production_id.workorder_ids
|
||||||
subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
subcontract_workorders = workorders.filtered(
|
||||||
|
lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence')
|
||||||
if self == subcontract_workorders[-1]:
|
if self == subcontract_workorders[-1]:
|
||||||
# 给下一个库存移动就绪
|
# 给下一个库存移动就绪
|
||||||
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
|
self.move_subcontract_workorder_ids[0].move_dest_ids._action_done()
|
||||||
@@ -1671,6 +1676,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# 根据工单对应的【作业_个性化记录】配置页签
|
# 根据工单对应的【作业_个性化记录】配置页签
|
||||||
if any(item.code == 'PTD' for item in mw.routing_workcenter_id.individuation_page_ids):
|
if any(item.code == 'PTD' for item in mw.routing_workcenter_id.individuation_page_ids):
|
||||||
mw.individuation_page_PTD = True
|
mw.individuation_page_PTD = True
|
||||||
|
|
||||||
# =============================================================================================
|
# =============================================================================================
|
||||||
|
|
||||||
is_inspect = fields.Boolean('需送检', compute='_compute_is_inspect', store=True, default=False)
|
is_inspect = fields.Boolean('需送检', compute='_compute_is_inspect', store=True, default=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user