diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ff2fde3a..aca3e992 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -77,9 +77,10 @@ class MrpProduction(models.Model): ('pending_cam', '待加工'), ('progress', '加工中'), ('rework', '返工'), + ('scrap', '报废'), ('to_close', 'To Close'), ('done', 'Done'), - ('cancel', '报废')], string='State', + ('cancel', '已取消')], string='State', compute='_compute_state', copy=False, index=True, readonly=True, store=True, tracking=True, help=" * Draft: The MO is not confirmed yet.\n" @@ -166,7 +167,7 @@ class MrpProduction(models.Model): production.state = 'pending_cam' if production.state == 'progress': - if all(wo_state not in ('progress', 'done', 'rework') for wo_state in + if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in production.workorder_ids.mapped('state')): production.state = 'pending_cam' if production.is_rework is True: @@ -184,9 +185,11 @@ class MrpProduction(models.Model): for wo in production.workorder_ids): production.state = 'rework' + if any(wo.test_results == '报废' and wo.state == 'done' for wo in production.workorder_ids): + production.state = 'scrap' # 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工 - # if production.tool_state == '2': - # production.state = 'rework' + if production.tool_state == '2': + production.state = 'rework' def action_check(self): """ @@ -866,7 +869,7 @@ class MrpProduction(models.Model): if download_state is False: raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no)) productions = self.env['mrp.production'].search( - [('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))]) + [('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done', 'scrap'))]) if productions: for production in productions: panel_workorder = production.workorder_ids.filtered(lambda diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ed4786cd..a38f5f77 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1144,7 +1144,8 @@ class ResMrpWorkOrder(models.Model): 'detailed_reason': record.detailed_reason, 'processing_panel': record.processing_panel, 'routing_type': record.routing_type, - 'handle_result': '待处理' if record.test_results == '返工' 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_report': record.detection_report})], 'is_scrap': True if record.test_results == '报废' else False}) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 41392409..e389206d 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 69aed55e..06cb74e4 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -122,15 +122,15 @@ groups="sf_base.group_sf_mrp_user"/> -