优化文件内容
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -41,16 +41,16 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">-->
|
||||
<!-- <field name="name">mrp.production.workorder.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <field name="production_id" position="after">-->
|
||||
<!-- <field name="processing_panel" readonly="1"/>-->
|
||||
<!-- </field>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">-->
|
||||
<!-- <field name="name">mrp.production.workorder.form.inherit.sf</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>-->
|
||||
<!-- <field name="arch" type="xml">-->
|
||||
<!-- <field name="production_id" position="after">-->
|
||||
<!-- <field name="processing_panel" readonly="1"/>-->
|
||||
<!-- </field>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="view_mrp_production_workorder_tray_form_inherit_sf" model="ir.ui.view">
|
||||
<field name="name">mrp.production.workorder.tray.form.inherit.sf</field>
|
||||
@@ -210,11 +210,12 @@
|
||||
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<field name="cnc_ids" widget="one2many">
|
||||
<group>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序">
|
||||
<tree>
|
||||
<field name="cnc_id"/>
|
||||
<field name="sequence_number"/>
|
||||
<field name="program_name"/>
|
||||
<field name="cnc_id" string="文件"/>
|
||||
<field name="cutting_tool_name"/>
|
||||
<field name="cutting_tool_no"/>
|
||||
<field name="processing_type"/>
|
||||
@@ -227,6 +228,8 @@
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="cnc_worksheet" string="工作指令" widget="pdf_viewer"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user