diff --git a/sf_machine_connect/views/compensation.xml b/sf_machine_connect/views/compensation.xml
index 55036c8d..7668d818 100644
--- a/sf_machine_connect/views/compensation.xml
+++ b/sf_machine_connect/views/compensation.xml
@@ -20,12 +20,12 @@
-
-
-
-
-
-
+
diff --git a/sf_machine_connect/views/ftp_button.xml b/sf_machine_connect/views/ftp_button.xml
index 2a273553..f102dc00 100644
--- a/sf_machine_connect/views/ftp_button.xml
+++ b/sf_machine_connect/views/ftp_button.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/sf_machine_connect/wizard/up_select.xml b/sf_machine_connect/wizard/up_select.xml
index 6ffbbfc5..cbdac5b3 100644
--- a/sf_machine_connect/wizard/up_select.xml
+++ b/sf_machine_connect/wizard/up_select.xml
@@ -14,7 +14,7 @@
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index f2876350..70db2915 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -311,6 +311,14 @@ class MrpProduction(models.Model):
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self, item):
+ # 根据product_id对self进行分组
+ grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
+ # 初始化一个字典来存储每个product_id对应的生产订单名称列表
+ product_id_to_production_names = {}
+ # 对于每个product_id,获取其所有生产订单的名称
+ for product_id, productions in grouped_product_ids.items():
+ # 为同一个product_id创建一个生产订单名称列表
+ product_id_to_production_names[product_id] = [production.name for production in productions]
for production in self:
if not production.bom_id or not production.product_id:
continue
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 09270dae..b4c7170f 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -207,7 +207,7 @@ class ResMrpWorkOrder(models.Model):
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
- # is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
+ is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
@api.onchange('rfid_code')
def _onchange(self):
@@ -1036,7 +1036,7 @@ class ResMrpWorkOrder(models.Model):
if raw_move:
raw_move.write({'state': 'done'})
record.production_id.button_mark_done1()
- record.production_id.state = 'done'
+ # self.production_id.state = 'done'
# 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath):
@@ -1079,30 +1079,31 @@ class ResMrpWorkOrder(models.Model):
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 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:
+ workorder.write({'is_send_program_again': True})
+ 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程序失败,请联系管理员")
class CNCprocessing(models.Model):
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index ee24b72c..c7ae6ecc 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -211,7 +211,7 @@ class StockRule(models.Model):
'''
# productions._create_workorder()
#
- # self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
+ self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
(
p.move_dest_ids.procure_method != 'make_to_order' and not
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index bf353a40..790c0551 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -124,7 +124,7 @@
-
+
@@ -160,11 +160,11 @@
-
-
-
-
-
+
diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py
index 4666fd99..b6d4c659 100644
--- a/sf_mrs_connect/controllers/controllers.py
+++ b/sf_mrs_connect/controllers/controllers.py
@@ -73,7 +73,8 @@ class Sf_Mrs_Connect(http.Controller):
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
cnc_workorder.write(
- {'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret),
+ {'is_send_program_again': False,
+ 'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret),
'cmm_ids': cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel, ret),
'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
pre_workorder = production.workorder_ids.filtered(
@@ -81,7 +82,8 @@ class Sf_Mrs_Connect(http.Controller):
'cancel'] and ap.processing_panel == panel)
if pre_workorder:
pre_workorder.write(
- {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
+ {'is_send_program_again': False,
+ 'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
cnc_program_ids = [item.id for item in productions]
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(