diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index f4a17f1a..11931f4c 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 基础模块', + 'name': '机企猫智能工厂 基础配置', 'version': '1.0', 'summary': '智能工厂基础模块', 'sequence': 1, diff --git a/sf_bf_connect/__manifest__.py b/sf_bf_connect/__manifest__.py index 1c89889d..4229609b 100644 --- a/sf_bf_connect/__manifest__.py +++ b/sf_bf_connect/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 连接业务平台模块', + 'name': '机企猫智能工厂 对接业务平台', 'version': '1.0', 'summary': '连接业务平台模块', 'sequence': 1, diff --git a/sf_dlm/__manifest__.py b/sf_dlm/__manifest__.py index 1cd1e995..9fc39be7 100644 --- a/sf_dlm/__manifest__.py +++ b/sf_dlm/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 产品模块', + 'name': '机企猫智能工厂 产品管理', 'version': '1.0', 'summary': '智能工厂产品模块', 'sequence': 1, diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index c54ff1ff..2f73f417 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 制造模块', + 'name': '机企猫智能工厂 制造管理', 'version': '1.0', 'summary': '智能工厂制造模块', 'sequence': 1, diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 9b7bd278..b6cdc3b2 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -4,6 +4,7 @@ import math import requests import logging import base64 +# import subprocess from datetime import datetime from dateutil.relativedelta import relativedelta from odoo import api, fields, models, SUPERUSER_ID, _ @@ -13,7 +14,6 @@ from odoo.exceptions import UserError from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController - class ResMrpWorkOrder(models.Model): _inherit = 'mrp.workorder' _order = 'sequence' @@ -29,6 +29,8 @@ class ResMrpWorkOrder(models.Model): ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), ], string="工序类型") + cnc_worksheet = fields.Binary( + '工作指令', readonly=True) material_center_point = fields.Char(string='配料中心点') X1_axis = fields.Float(default=0) Y1_axis = fields.Float(default=0) @@ -337,12 +339,12 @@ class CNCprocessing(models.Model): depth_of_processing_z = fields.Char('加工深度(Z)') cutting_tool_extension_length = fields.Char('刀具伸出长度') cutting_tool_handle_type = fields.Char('刀柄型号') - estimated_processing_time = fields.Char('预计加工时间') + estimated_processing_time = fields.Datetime('预计加工时间') remark = fields.Text('备注') workorder_id = fields.Many2one('mrp.workorder', string="工单") # mrs下发编程单创建CNC加工 - def CNCprocessing_create(self, obj): + def cnc_processing_create(self, obj): workorder = self.env['mrp.workorder'].search([('production_id.name', '=', obj['manufacturing_order_no']), ('processing_panel', '=', obj['processing_panel']), ('routing_type', '=', 'CNC加工')]) @@ -363,6 +365,7 @@ class CNCprocessing(models.Model): } return self.env['sf.cnc.processing'].create(vals) + # 创建附件(nc文件) def attachment_create(self, name, data): attachment = self.env['ir.attachment'].create({ 'datas': base64.b64encode(data), @@ -372,6 +375,7 @@ class CNCprocessing(models.Model): }) return attachment + # 将FTP的nc文件下载到临时目录 def download_file_tmp(self, model_code, processing_panel): remotepath = os.path.join('/', model_code, 'return', processing_panel) serverdir = os.path.join('/tmp', model_code, 'return', processing_panel) @@ -379,6 +383,7 @@ class CNCprocessing(models.Model): ftp.download_file_tree(remotepath, serverdir) return serverdir + # 将nc文件存到attach的datas里 def write_file(self, nc_file_path, cnc): if os.path.exists(nc_file_path): with open(nc_file_path, 'rb') as file: @@ -389,6 +394,20 @@ class CNCprocessing(models.Model): else: return False + # 将nc文件对应的excel清单转为pdf + # def to_pdf(self, excel_path, pdf_path): + # """ + # 需要在linux中下载好libreoffice + # """ + # logging.info('pdf_path:%s' % pdf_path) + # logging.info('pdf_path:%s' % excel_path) + # # 注意cmd中的libreoffice要和linux中安装的一致 + # cmd = 'soffice --headless --convert-to pdf'.split() + [excel_path] + ['--outdir'] + [pdf_path] + # p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1) + # # p.wait(timeout=30) # 停顿30秒等待转化 + # # stdout, stderr = p.communicate() + # p.communicate() + class SfWorkOrderBarcodes(models.Model): """ @@ -402,4 +421,3 @@ class SfWorkOrderBarcodes(models.Model): self.tray_code = tray_code.code workorder = self.env['mrp.workorder'].browse(self.ids) workorder.gettray_auto(barcode) - diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 973f507b..38618e11 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -41,16 +41,16 @@ - - - - - - - - - - + + + + + + + + + + mrp.production.workorder.tray.form.inherit.sf @@ -210,23 +210,26 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/sf_mrs_connect/__manifest__.py b/sf_mrs_connect/__manifest__.py index ed57fe43..639f16e6 100644 --- a/sf_mrs_connect/__manifest__.py +++ b/sf_mrs_connect/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 连接制造资源库模块 ', + 'name': '机企猫智能工厂 对接制造资源库 ', 'version': '1.0', 'summary': '智能工厂连接制造资源库模块', 'sequence': 1, diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index dea7ec60..f0ada0a3 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import json +import base64 import logging import os from datetime import date, timedelta @@ -23,12 +24,27 @@ class Sf_Mrs_Connect(http.Controller): ret = json.loads(datas) ret = json.loads(ret['result']) for obj in ret: - cnc = request.env['sf.cnc.processing'].with_user(request.env.ref("base.user_admin")).CNCprocessing_create(obj) - # 从ftp拉取对应的文件 + cnc = request.env['sf.cnc.processing'].with_user( + request.env.ref("base.user_admin")).cnc_processing_create(obj) + # # 从ftp拉取对应的文件 model_code = cnc.workorder_id.product_id.barcode processing_panel = cnc.workorder_id.processing_panel - server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code, processing_panel) + server_dir = cnc.with_user(request.env.ref("base.user_admin")).download_file_tmp(model_code, + processing_panel) cnc_file_path = os.path.join(server_dir, cnc.program_name + '.NC') cnc.with_user(request.env.ref("base.user_admin")).write_file(cnc_file_path, cnc) + # logging.info('get_cnc_processing_create:%s' % '111111111111111') + # for root, dirs, files in os.walk(server_dir): + # for file in files: + # if os.path.splitext(file)[1] == '.xlsx' or os.path.splitext(file)[1] == ".xls": + # pdf_path = os.path.splitext(file)[1] + '.PDF' + # cnc_pdf_path = request.env['sf.cnc.processing'].with_user( + # request.env.ref("base.user_admin")).to_pdf(os.path.join(root, file), pdf_path) + # if pdf_path != False: + # if not cnc.workorder_id.cnc_worksheet: + # cnc.workorder_id.cnc_worksheet = base64.b64encode(open(cnc_pdf_path, 'rb').read()) + # else: + # logging.info('break:%s' % 'break') + # break except Exception as e: logging.info('get_cnc_processing_create error:%s' % e) diff --git a/sf_sale/__manifest__.py b/sf_sale/__manifest__.py index 5ae9ba8b..2181f64a 100644 --- a/sf_sale/__manifest__.py +++ b/sf_sale/__manifest__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. { - 'name': '机企猫智能工厂 销售模块', + 'name': '机企猫智能工厂 销售管理', 'version': '1.0', 'summary': '智能工厂销售模块', 'sequence': 1,