From 77f7602b23460109e9fec8b61a9c9c4c215c1b94 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 17 Jul 2024 19:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E9=9D=A2=E8=BF=94?= =?UTF-8?q?=E5=B7=A5=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 3 +- sf_manufacturing/models/mrp_workorder.py | 75 +++++++------------ .../views/mrp_production_addional_change.xml | 5 +- sf_manufacturing/wizard/rework_wizard.py | 6 +- 4 files changed, 40 insertions(+), 49 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index b965a63e..39c44e80 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -56,7 +56,8 @@ class MrpProduction(models.Model): reprogramming_num = fields.Integer('重新编程次数', default=0) work_state = fields.Char('业务状态') programming_state = fields.Selection( - [('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')], string='编程状态', + [('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发'), ('已下发', '已下发')], + string='编程状态', tracking=True) glb_file = fields.Binary("glb模型文件") production_line_id = fields.Many2one('sf.production.line', string='生产线', tracking=True) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index b065284b..692dde1a 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -827,28 +827,37 @@ 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'])]) - logging.info('re_work:%s' % re_work.state) if workorder.state not in ['cancel', 'progress', 'rework']: - logging.info('工序:%s' % workorder.routing_type) - logging.info('状态:%s' % workorder.state) - logging.info('is_rework:%s' % workorder.is_rework) - logging.info('面:%s' % workorder.processing_panel) - logging.info('编程状态:%s' % workorder.production_id.programming_state) - logging.info('制造状态:%s' % workorder.production_id.state) - # if workorder.state =='done' and workorder.is_rework is True: - # workorder.state = 'rework' - # else: - # if re_work: - # workorder.state = 'rework' if workorder.production_id.state == 'rework': - if (workorder.routing_type == 'CNC加工' and workorder.state == 'done') or ( - workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '编程中' and re_work): - logging.info('面111:%s' % workorder.processing_panel) - workorder.state = 'waiting' + logging.info('len(re_work):%s' % len(re_work)) + logging.info('工序:%s' % workorder.routing_type) + logging.info('状态:%s' % workorder.state) + logging.info('is_rework:%s' % workorder.is_rework) + 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: + 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' elif workorder.production_id.state == 'progress': - logging.info('面222:%s' % workorder.processing_panel) - if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已下发' and re_work: - workorder.state = 'ready' + logging.info('len(re_work):%s' % len(re_work)) + logging.info('工序:%s' % workorder.routing_type) + logging.info('状态:%s' % workorder.state) + logging.info('is_rework:%s' % workorder.is_rework) + logging.info('面:%s' % workorder.processing_panel) + logging.info('编程状态:%s' % workorder.production_id.programming_state) + logging.info('制造状态:%s' % workorder.production_id.state) + if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已下发': + if re_work: + workorder.state = 'ready' # else: # if workorder.state not in ['cancel', 'rework']: # workorder.state = 'rework' @@ -988,7 +997,7 @@ class ResMrpWorkOrder(models.Model): if record.routing_type == '装夹预调': if not record.material_center_point and record.X_deviation_angle > 0: raise UserError("请对前置三元检测定位参数进行计算定位") - if not record.rfid_code: + if not record.rfid_code and record.is_rework is False: raise UserError("请扫RFID码进行绑定") record.process_state = '待加工' # record.write({'process_state': '待加工'}) @@ -1130,32 +1139,6 @@ class ResMrpWorkOrder(models.Model): workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read()) return True - # 重新下发nc程序 - # def button_send_program_again(self): - # try: - # res = {'programming_no': self.production_id.programming_no} - # configsettings = self.env['res.config.settings'].get_values() - # config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) - # url = '/api/intelligent_programming/reset_state_again' - # config_url = configsettings['sf_url'] + url - # r = requests.post(config_url, json=res, data=None, headers=config_header) - # r = r.json() - # result = json.loads(r['result']) - # if result['status'] == 1: - # productions = self.env['mrp.production'].search( - # [('programming_no', '=', self.production_id.programming_no), ('programming_state', '=', '已编程')]) - # if productions: - # workorder = productions.workorder_ids.filtered( - # lambda ap: ap.routing_type in ['装夹预调', 'CNC加工'] and ap.state not in ['done', 'cancel', - # 'progress']) - # if workorder: - # productions.write({'work_state': '编程中', 'programming_state': '编程中'}) - # else: - # raise UserError(result['message']) - # except Exception as e: - # logging.info('button_send_program_again error:%s' % e) - # raise UserError("重新下发nc程序失败,请联系管理员") - def print_method(self): """ 解除装夹处调用关联制造订单的关联序列号的打印方法 diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index ca4659e5..11d746da 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -455,6 +455,9 @@ + +
- +
diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index 2faf74d0..4ad7c163 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -81,10 +81,14 @@ class ReworkWizard(models.TransientModel): if production_id: if self.env.user.has_group('sf_base.group_sf_order_user'): panel_ids = [] + panel_arr = production_id.product_id.model_processing_panel for p in production_id.detection_result_ids.filtered( lambda ap1: ap1.handle_result == '待处理'): + if p.processing_panel not in panel_arr: + panel_arr += ','.join(p.processing_panel) + for item in panel_arr.split(','): panel = self.env['sf.processing.panel'].search( - [('name', 'ilike', p.processing_panel)]) + [('name', 'ilike', item)]) if panel: panel_ids.append(panel.id) domain = {'processing_panel_id': [('id', 'in', panel_ids)]}