From 28659bfc95fba809a555ca42f17620dd066d9d5e Mon Sep 17 00:00:00 2001
From: mgw <1392924357@qq.com>
Date: Thu, 23 Feb 2023 08:52:56 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=88=E5=B9=B6=E4=B8=8B?=
=?UTF-8?q?=E5=8F=91=E5=90=91=E5=AF=BC=EF=BC=8C=E5=A2=9E=E5=8A=A0cnc?=
=?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=9A=84=E7=BC=BA=E7=9C=81tree=E8=A7=86?=
=?UTF-8?q?=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_machine_connect/__init__.py | 3 +-
sf_machine_connect/__manifest__.py | 7 ++
sf_machine_connect/models/ftp_client.py | 19 ++-
.../security/ir.model.access.csv | 3 +-
sf_machine_connect/views/cnc.xml | 27 ++++
sf_machine_connect/views/compensation.xml | 6 +-
sf_machine_connect/views/delivery_record.xml | 32 +++++
sf_machine_connect/views/ftp_button.xml | 13 ++
sf_machine_connect/wizard/__init__.py | 1 +
sf_machine_connect/wizard/action_up.py | 116 ++++++++++++++++++
sf_machine_connect/wizard/up_select.xml | 34 +++++
sf_manufacturing/models/mrp_workorder.py | 3 +
sf_manufacturing/views/mrp_workorder_view.xml | 5 +-
13 files changed, 260 insertions(+), 9 deletions(-)
create mode 100644 sf_machine_connect/views/cnc.xml
create mode 100644 sf_machine_connect/views/delivery_record.xml
create mode 100644 sf_machine_connect/wizard/__init__.py
create mode 100644 sf_machine_connect/wizard/action_up.py
create mode 100644 sf_machine_connect/wizard/up_select.xml
diff --git a/sf_machine_connect/__init__.py b/sf_machine_connect/__init__.py
index 9a7e03ed..c536983e 100644
--- a/sf_machine_connect/__init__.py
+++ b/sf_machine_connect/__init__.py
@@ -1 +1,2 @@
-from . import models
\ No newline at end of file
+from . import models
+from . import wizard
\ No newline at end of file
diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py
index 646a9403..2a78595b 100644
--- a/sf_machine_connect/__manifest__.py
+++ b/sf_machine_connect/__manifest__.py
@@ -16,13 +16,20 @@
'data': [
# 定义权限组放在最上面
# 权限组
+ 'security/ir.model.access.csv',
+ 'wizard/up_select.xml',
+ 'views/cnc.xml',
+
'views/compensation.xml',
'views/ftp_button.xml',
+
'views/SfWorkOrderBarcodes.xml',
'views/WorkCenterBarcodes.xml',
'views/Stock_picking_Barcodes.xml',
'views/machine_monitor.xml',
'views/machine_info_present.xml',
+ 'views/delivery_record.xml',
+
],
'assets': {
diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py
index 40c7ca3c..49868871 100644
--- a/sf_machine_connect/models/ftp_client.py
+++ b/sf_machine_connect/models/ftp_client.py
@@ -23,7 +23,6 @@ _logger = logging.getLogger(__name__)
class FtpButton(models.Model):
_inherit = 'sf.cnc.processing'
- button_state = fields.Boolean(string='是否已经下发')
user_permissions = fields.Boolean(string='权限', related='workorder_id.user_permissions')
state = fields.Selection(string='状态', related='workorder_id.state')
@@ -301,12 +300,13 @@ class WorkCenterBarcode(models.Model):
# 存在本地的文件下发到机床
_logger.info("=====================11================")
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
+ item.button_state = True
# _logger.info("=====================22================")
except Exception as e:
_logger.info("=====================================", e)
raise UserError('NC下发执行超时, 请检查下发状态')
- # 下发都执行完毕后,按钮标志位变为true
- self.button_up_all_state = True
+ # # 下发都执行完毕后,按钮标志位变为true
+ # self.cnc_ids.button_state = True
def get__state(self):
pay_time = str(datetime.now())
@@ -338,3 +338,16 @@ class WorkCenterBarcode(models.Model):
}
url = 'https://bfm.cs.jikimo.com/api/get/state'
requests.post(url, json=json, data=None)
+
+ def action_up_select(self):
+ return {
+ 'name': '选择要下发的程序文件',
+ 'view_mode': 'tree,form',
+ # 'res_model': self._name,
+ 'res_model': 'sf_tray_form_inherit',
+ 'target': 'main', # 打开方式
+ # 'domain': [('project_num', '=', self.project_num), ('state', '=', 'done')], # 域
+ 'type': 'ir.actions.act_window', # 返回的类型
+ }
+
+
diff --git a/sf_machine_connect/security/ir.model.access.csv b/sf_machine_connect/security/ir.model.access.csv
index 53d13813..97e855f9 100644
--- a/sf_machine_connect/security/ir.model.access.csv
+++ b/sf_machine_connect/security/ir.model.access.csv
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_ftp_client,ftp.client,model_ftp_client,base.group_user,1,1,1,1
+
+access_up_select_wizard,up.select.wizard,model_up_select_wizard,base.group_user,1,1,1,1
diff --git a/sf_machine_connect/views/cnc.xml b/sf_machine_connect/views/cnc.xml
new file mode 100644
index 00000000..1883d496
--- /dev/null
+++ b/sf_machine_connect/views/cnc.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ sf.cnc.tree
+ sf.cnc.processing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_machine_connect/views/compensation.xml b/sf_machine_connect/views/compensation.xml
index 77ee1012..54652138 100644
--- a/sf_machine_connect/views/compensation.xml
+++ b/sf_machine_connect/views/compensation.xml
@@ -19,11 +19,13 @@
class="btn-primary" attrs='{"invisible": ["|",
("state","!=","progress"),("user_permissions","=",False)]}'/>
-
+
+
+
+
diff --git a/sf_machine_connect/views/delivery_record.xml b/sf_machine_connect/views/delivery_record.xml
new file mode 100644
index 00000000..b62202e0
--- /dev/null
+++ b/sf_machine_connect/views/delivery_record.xml
@@ -0,0 +1,32 @@
+
+
+
+ delivery.record.form.inherit.sf
+ mrp.workorder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_machine_connect/views/ftp_button.xml b/sf_machine_connect/views/ftp_button.xml
index e56ea01a..17924377 100644
--- a/sf_machine_connect/views/ftp_button.xml
+++ b/sf_machine_connect/views/ftp_button.xml
@@ -26,5 +26,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sf_machine_connect/wizard/__init__.py b/sf_machine_connect/wizard/__init__.py
new file mode 100644
index 00000000..5faba653
--- /dev/null
+++ b/sf_machine_connect/wizard/__init__.py
@@ -0,0 +1 @@
+from . import action_up
\ No newline at end of file
diff --git a/sf_machine_connect/wizard/action_up.py b/sf_machine_connect/wizard/action_up.py
new file mode 100644
index 00000000..00e5068b
--- /dev/null
+++ b/sf_machine_connect/wizard/action_up.py
@@ -0,0 +1,116 @@
+# -*- coding: utf-8 -*-
+import base64
+import logging
+import os
+import json
+import hashlib
+import time
+import requests
+from datetime import datetime
+
+from odoo import fields, models, api, _
+from odoo.exceptions import ValidationError
+from odoo.exceptions import UserError
+from odoo.addons.sf_machine_connect.models import py2opcua, ftp_operate
+
+_logger = logging.getLogger(__name__)
+
+
+class UpSelectWizard(models.TransientModel):
+ _name = 'up.select.wizard'
+
+ workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
+ workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', related='workorder_id.workcenter_id', readonly=True)
+ program_ids = fields.Many2many('sf.cnc.processing', string='程序列表')
+
+ def confirm_up(self):
+ pass
+
+ # cnc_id1 = fields.Many2one('ir.attachment', compute='_compute_cnc_id')
+ # sequence_number1 = fields.Char('序号', compute='_compute_cnc_id', default='0')
+ # program_name1 = fields.Char('程序名', compute='_compute_cnc_id')
+ # cutting_tool_name1 = fields.Char('刀具名称', compute='_compute_cnc_id')
+ # cutting_tool_no1 = fields.Char('刀号', compute='_compute_cnc_id')
+ # processing_type1 = fields.Char('加工类型', compute='_compute_cnc_id')
+ # margin_x_y1 = fields.Char('余量_X/Y', compute='_compute_cnc_id')
+ # margin_z1 = fields.Char('余量_Z', compute='_compute_cnc_id')
+ # depth_of_processing_z1 = fields.Char('加工深度(Z)', compute='_compute_cnc_id')
+ # cutting_tool_extension_length1 = fields.Char('刀具伸出长度', compute='_compute_cnc_id')
+ # cutting_tool_handle_type1 = fields.Char('刀柄型号', compute='_compute_cnc_id')
+ # estimated_processing_time1 = fields.Char('预计加工时间', compute='_compute_cnc_id')
+ # remark1 = fields.Text('备注', compute='_compute_cnc_id')
+ # cnc_id = fields.Many2one('sf.cnc.processing', '工单')
+ # num = fields.Integer('索引', default=0)
+ # cnc_id1 = fields.Many2one('ir.attachment')
+ # sequence_number1 = fields.Char('序号', compute='_compute_cnc_id', default='1')
+ # program_name1 = fields.Char('程序名')
+ # cutting_tool_name1 = fields.Char('刀具名称')
+ # cutting_tool_no1 = fields.Char('刀号')
+ # processing_type1 = fields.Char('加工类型')
+ # margin_x_y1 = fields.Char('余量_X/Y')
+ # margin_z1 = fields.Char('余量_Z')
+ # depth_of_processing_z1 = fields.Char('加工深度(Z)')
+ # cutting_tool_extension_length1 = fields.Char('刀具伸出长度')
+ # cutting_tool_handle_type1 = fields.Char('刀柄型号')
+ # estimated_processing_time1 = fields.Char('预计加工时间')
+ # remark1 = fields.Text('备注')
+ # cnc_id = fields.Many2one('sf.cnc.processing', '工单')
+ # num = fields.Integer('索引', default=0)
+ # print(11111111111111111111111111111111111111111111111)
+ # # @api.depends('program_ids')
+ # def _compute_cnc_id(self):
+ # print(222222222222222222222222222222222222222222)
+ # workorder_id = self.env.context.get('default_workorder_id')
+ # workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id)])
+ # # self.workcenter_id = workorder.workcent_id
+ # print(workorder_id)
+ #
+ # lines = []
+ # print(lines)
+ # for item in workorder.cnc_ids:
+ # # lines.append((4,item.id,0))
+ # lines.append((4, item.id, 0))
+ # print(lines)
+ #
+ # # print(self.cnc_id1, self.sequence_number1, self.program_name1, self.processing_type1,
+ # # self.cutting_tool_handle_type1
+ # # , self.cutting_tool_extension_length1, self.margin_z1, self.margin_z1, self.depth_of_processing_z1,
+ # # self.cutting_tool_no1, self.cutting_tool_name1, self.estimated_processing_time1, self.remark1)
+ # # else:
+ # # self.write({
+ # #
+ # # # 'cnc_id1': item.cnc_id or '',
+ # # # 'sequence_number1': item.sequence_number or '',
+ # # # 'program_name1': item.program_name or '',
+ # # # 'cutting_tool_name1': item.cutting_tool_name or '',
+ # # # 'cutting_tool_no1': item.cutting_tool_no or '',
+ # # # 'processing_type1': item.processing_type or '',
+ # # # 'margin_x_y1': item.margin_x_y or '',
+ # # # 'margin_z1': item.margin_z or '',
+ # # # 'depth_of_processing_z1': item.depth_of_processing_z or '',
+ # # # 'cutting_tool_extension_length1': item.cutting_tool_extension_length or '',
+ # # # 'cutting_tool_handle_type1': item.cutting_tool_handle_type or '',
+ # # # 'estimated_processing_time1': item.estimated_processing_time or '',
+ # # # 'remark1': item.remark or '',
+ # # 'id': item.sequence_number,
+ # # 'cnc_id1': item.cnc_id,
+ # # 'sequence_number1': item.sequence_number,
+ # # 'program_name1': item.program_name,
+ # # 'cutting_tool_name1': item.cutting_tool_name,
+ # # 'cutting_tool_no1': item.cutting_tool_no,
+ # # 'processing_type1': item.processing_type,
+ # # 'margin_x_y1': item.margin_x_y,
+ # # 'margin_z1': item.margin_z,
+ # # 'depth_of_processing_z1': item.depth_of_processing_z,
+ # # 'cutting_tool_extension_length1': item.cutting_tool_extension_length,
+ # # 'cutting_tool_handle_type1': item.cutting_tool_handle_type,
+ # # 'estimated_processing_time1': item.estimated_processing_time,
+ # # 'remark1': item.remark,
+ # # })
+ # # print(self.cnc_id1, self.sequence_number1, self.program_name1, self.processing_type1,
+ # # self.cutting_tool_handle_type1
+ # # , self.cutting_tool_extension_length1, self.margin_z1, self.margin_z1,
+ # # self.depth_of_processing_z1,
+ # # self.cutting_tool_no1, self.cutting_tool_name1, self.estimated_processing_time1, self.remark1)
+ #
+ # self.update({'program_ids': lines})
diff --git a/sf_machine_connect/wizard/up_select.xml b/sf_machine_connect/wizard/up_select.xml
new file mode 100644
index 00000000..cbdac5b3
--- /dev/null
+++ b/sf_machine_connect/wizard/up_select.xml
@@ -0,0 +1,34 @@
+
+
+
+ CNC工单
+ up.select.wizard
+
+
+
+
+
+ 选择要下发的NC程序
+ ir.actions.act_window
+
+ up.select.wizard
+ form
+
+ new
+
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 852db2d7..4e3f410b 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -431,6 +431,7 @@ class ResMrpWorkOrder(models.Model):
class CNCprocessing(models.Model):
_name = 'sf.cnc.processing'
_description = "CNC加工"
+ _rec_name = 'program_name'
cnc_id = fields.Many2one('ir.attachment')
sequence_number = fields.Char('序号')
@@ -446,6 +447,8 @@ class CNCprocessing(models.Model):
estimated_processing_time = fields.Char('预计加工时间')
remark = fields.Text('备注')
workorder_id = fields.Many2one('mrp.workorder', string="工单")
+ button_state = fields.Boolean(string='是否已经下发')
+
# mrs下发编程单创建CNC加工
def cnc_processing_create(self, cnc_workorder, ret):
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 2a847788..3529b6a6 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -336,11 +336,11 @@
-
+
-
+
@@ -350,6 +350,7 @@
+