diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 002c83aa..07409827 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1,5 +1,5 @@ import re - +import json import logging import base64 import urllib.parse @@ -1066,6 +1066,25 @@ 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: + self.production_id.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程序失败,请联系管理员") + class CNCprocessing(models.Model): _name = 'sf.cnc.processing' diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 11219363..26f8941d 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -151,7 +151,10 @@