diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 6624e709..33939c72 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -242,7 +242,7 @@ class Manufacturing_Connect(http.Controller): logging.info('button_Work_End error:%s' % e) return json.JSONEncoder().encode(res) - @http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False, cors="*") def PartQualityInspect(self, **kw): """ diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index f389b05b..d650d865 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -241,7 +241,7 @@ class MrpProduction(models.Model): if rp.programming_no == item['programming_no']: rp.write({'programming_state': '已编程未下发' if item[ 'programming_state'] == '已编程' else '编程中'}) - logging.info('rp:' % rp.name) + logging.info('rp:%s' % rp.name) else: return item @@ -800,11 +800,7 @@ class MrpProduction(models.Model): 'default_production_id': self.id, 'default_reprogramming_num': cloud_programming['reprogramming_num'], 'default_programming_state': cloud_programming['programming_state'], - 'default_is_reprogramming': False if (cloud_programming['programming_state'] in ['编程中', - '待编程'] and self.programming_state in [ - '编程中', '已编程']) - or (cloud_programming['programming_state'] in [ - '已编程'] and self.programming_state in ['已编程未下发']) else True + 'default_is_reprogramming': False if cloud_programming['programming_state'] not in ['已下发'] else True } } @@ -829,6 +825,8 @@ class MrpProduction(models.Model): program_to_production_names[programming_no] = [production.name for production in program_production] for production in self: if production.programming_no in program_to_production_names: + productions_not_delivered = self.env['mrp.production'].search( + [('programming_no', '=', production.programming_no), ('programming_state', '=', '已编程未下发')]) rework_workorder = production.workorder_ids.filtered(lambda m: m.state == 'rework') if rework_workorder: for rework_item in rework_workorder: @@ -837,7 +835,8 @@ class MrpProduction(models.Model): 'pending'] and m1.processing_panel == rework_item.processing_panel and m1.routing_type == 'CNC加工') if not pending_workorder.cnc_ids: production.get_new_program(rework_item.processing_panel) - production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False}) + # production.write({'state': 'progress', 'programming_state': '已编程', 'is_rework': False}) + productions_not_delivered.write({'programming_state': '已编程', 'is_rework': False}) # 从cloud获取重新编程过的最新程序 def get_new_program(self, processing_panel): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 0522126e..303a4966 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -741,9 +741,15 @@ class ResMrpWorkOrder(models.Model): 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', '=', '返工')]) if workorder.state not in ['cancel', 'progress', 'rework']: if workorder.production_id.state == 'rework': logging.info('len(re_work):%s' % len(re_work)) + logging.info('len(cnc_workorder):%s' % len(cnc_workorder)) logging.info('工序:%s' % workorder.routing_type) logging.info('状态:%s' % workorder.state) logging.info('is_rework:%s' % workorder.is_rework) @@ -751,31 +757,37 @@ class ResMrpWorkOrder(models.Model): logging.info('面:%s' % workorder.processing_panel) logging.info('编程状态:%s' % workorder.production_id.programming_state) logging.info('制造状态:%s' % workorder.production_id.state) - if re_work: - if workorder.routing_type == '装夹预调' and workorder.state not in ['done', 'rework', - 'cancel'] and workorder.is_rework is False: - if workorder.production_id.programming_state == '已编程': - workorder.state = 'ready' + 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: + workorder.state = 'ready' else: if workorder.production_id.is_rework is True: - workorder.state = 'waiting' - if workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']: - pre_workorder = self.env['mrp.workorder'].search( - [('production_id', '=', workorder.production_id.id), - ('processing_panel', '=', workorder.processing_panel), - ('routing_type', '=', '装夹预调'), ('state', '=', 'done')]) - if pre_workorder: - workorder.state = 'waiting' - if workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']: - cnc_workorder = self.env['mrp.workorder'].search( - [('production_id', '=', workorder.production_id.id), - ('processing_panel', '=', workorder.processing_panel), - ('routing_type', '=', 'CNC加工'), ('state', '=', 'done'), - ('test_results', '=', '返工')]) - if cnc_workorder: + if re_work or cnc_workorder: + workorder.state = 'waiting' + + elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']: + pre_workorder = self.env['mrp.workorder'].search( + [('production_id', '=', workorder.production_id.id), + ('processing_panel', '=', workorder.processing_panel), + ('routing_type', '=', '装夹预调'), ('state', '=', 'done')]) + if pre_workorder: + if re_work: workorder.state = 'waiting' + elif workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']: + if cnc_workorder: + workorder.state = 'waiting' + # else: + # if workorder.production_id.is_rework is True: + # workorder.state = 'waiting' elif workorder.production_id.state == 'progress': logging.info('len(re_work):%s' % len(re_work)) + logging.info('len(cnc_workorder):%s' % len(cnc_workorder)) logging.info('工序:%s' % workorder.routing_type) logging.info('状态:%s' % workorder.state) logging.info('is_rework:%s' % workorder.is_rework) diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml index 524bb8ae..49274368 100644 --- a/sf_manufacturing/wizard/rework_wizard_views.xml +++ b/sf_manufacturing/wizard/rework_wizard_views.xml @@ -20,13 +20,13 @@ style='color:red;'/>次,且当前编程状态为 + decoration-danger="programming_state =='已编程'" readonly="1"/> + attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("is_reprogramming","=",False)]}'/>