优化odoo16工单视图展示问题
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,
|
||||
|
||||
@@ -51,10 +51,10 @@ class MrpProduction(models.Model):
|
||||
|
||||
def action_generate_serial(self):
|
||||
self.ensure_one()
|
||||
self.lot_producing_id = self.env['stock.production.lot'].create({
|
||||
self.lot_producing_id = self.env['stock.lot'].create({
|
||||
'product_id': self.product_id.id,
|
||||
'company_id': self.company_id.id,
|
||||
'name': self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
|
||||
'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
|
||||
'ir.sequence'].next_by_code('stock.lot.serial'),
|
||||
})
|
||||
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:
|
||||
|
||||
@@ -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)
|
||||
@@ -61,7 +63,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
Y10_axis = fields.Float(default=0)
|
||||
Z10_axis = fields.Float(default=0)
|
||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果")
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
|
||||
tray_code = fields.Char(string="托盘")
|
||||
|
||||
@@ -337,12 +340,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 +366,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 +376,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 +384,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 +395,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 +422,3 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
self.tray_code = tray_code.code
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
workorder.gettray_auto(barcode)
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ class StockRule(models.Model):
|
||||
|
||||
|
||||
class ProductionLot(models.Model):
|
||||
_inherit = 'stock.production.lot'
|
||||
_inherit = 'stock.lot'
|
||||
|
||||
@api.model
|
||||
def generate_lot_names1(self, display_name, first_lot, count):
|
||||
@@ -217,10 +217,10 @@ class ProductionLot(models.Model):
|
||||
def _get_next_serial(self, company, product):
|
||||
"""Return the next serial number to be attributed to the product."""
|
||||
if product.tracking == "serial":
|
||||
last_serial = self.env['stock.production.lot'].search(
|
||||
last_serial = self.env['stock.lot'].search(
|
||||
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
||||
limit=1, order='id DESC')
|
||||
if last_serial:
|
||||
return self.env['stock.production.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
|
||||
return self.env['stock.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
|
||||
1]
|
||||
return "%s-%03d" % (product.display_name, 1)
|
||||
|
||||
@@ -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>
|
||||
@@ -71,11 +71,12 @@
|
||||
<field name="routing_type" invisible="1"/>
|
||||
<field name="processing_panel" readonly="1"/>
|
||||
<field name="tray_code"/>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
|
||||
</group>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="gettray" string="绑定托盘"
|
||||
attrs='{"invisible": [("production_id","=",False)]}'/>
|
||||
</div>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
@@ -86,121 +87,107 @@
|
||||
<field name="processing_panel" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<div>左面:</div>
|
||||
<div>左面:</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X1_axis" string="x"/>
|
||||
<field name="X1_axis" class="o_form_label"/>
|
||||
<label for="Y1_axis" string="y"/>
|
||||
<field name="Y1_axis" class="o_form_label"/>
|
||||
<label for="Z1_axis" string="z"/>
|
||||
<field name="Z1_axis" class="o_form_label"/>
|
||||
<div></div>
|
||||
<div class="o_address_format">
|
||||
<label for="X1_axis" string="x1"/>
|
||||
<field name="X1_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y1_axis" string="y1"/>
|
||||
<field name="Y1_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z1_axis" string="z1"/>
|
||||
<field name="Z1_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X2_axis" string="x2"/>
|
||||
<field name="X2_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y2_axis" string="y2"/>
|
||||
<field name="Y2_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z2_axis" string="z2"/>
|
||||
<field name="Z2_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div>前面:</div>
|
||||
<label for="X2_axis" string="x"/>
|
||||
<field name="X2_axis" class="o_form_label"/>
|
||||
<label for="Y2_axis" string="y"/>
|
||||
<field name="Y2_axis" class="o_form_label"/>
|
||||
<label for="Z2_axis" string="z"/>
|
||||
<field name="Z2_axis" class="o_form_label"/>
|
||||
</div>
|
||||
<div>前面:</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X3_axis" string="x"/>
|
||||
<field name="X3_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y3_axis" string="y"/>
|
||||
<field name="Y3_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z3_axis" string="z"/>
|
||||
<field name="Z3_axis" class="o_form_label"/>
|
||||
<div></div>
|
||||
<div class="o_address_format">
|
||||
<label for="X3_axis" string="x1"/>
|
||||
<field name="X3_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y3_axis" string="y1"/>
|
||||
<field name="Y3_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z3_axis" string="z1"/>
|
||||
<field name="Z3_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X4_axis" string="x2"/>
|
||||
<field name="X4_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y4_axis" string="y2"/>
|
||||
<field name="Y4_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z4_axis" string="z2"/>
|
||||
<field name="Z4_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div>右面:</div>
|
||||
<label for="X4_axis" string="x"/>
|
||||
<field name="X4_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y4_axis" string="y"/>
|
||||
<field name="Y4_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z4_axis" string="z"/>
|
||||
<field name="Z4_axis" class="o_form_label"/>
|
||||
</div>
|
||||
<div>右面:</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X5_axis" string="x"/>
|
||||
<field name="X5_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y5_axis" string="y"/>
|
||||
<field name="Y5_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z5_axis" string="z"/>
|
||||
<field name="Z5_axis" class="o_form_label"/>
|
||||
<div></div>
|
||||
<div class="o_address_format">
|
||||
<label for="X5_axis" string="x1"/>
|
||||
<field name="X5_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y5_axis" string="y1"/>
|
||||
<field name="Y5_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z5_axis" string="z1"/>
|
||||
<field name="Z5_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X6_axis" string="x2"/>
|
||||
<field name="X6_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y6_axis" string="y2"/>
|
||||
<field name="Y6_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z6_axis" string="z2"/>
|
||||
<field name="Z6_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div>后面:</div>
|
||||
<label for="X6_axis" string="x"/>
|
||||
<field name="X6_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y6_axis" string="y"/>
|
||||
<field name="Y6_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z6_axis" string="z"/>
|
||||
<field name="Z6_axis" class="o_form_label"/>
|
||||
</div>
|
||||
<div>后面:</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X7_axis" string="x"/>
|
||||
<field name="X7_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y7_axis" string="y"/>
|
||||
<field name="Y7_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z7_axis" string="z"/>
|
||||
<field name="Z7_axis" class="o_form_label"/>
|
||||
<div></div>
|
||||
<div class="o_address_format">
|
||||
<label for="X7_axis" string="x1"/>
|
||||
<field name="X7_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y7_axis" string="y1"/>
|
||||
<field name="Y7_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z7_axis" string="z1"/>
|
||||
<field name="Z7_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X8_axis" string="x2"/>
|
||||
<field name="X8_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y8_axis" string="y2"/>
|
||||
<field name="Y8_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z8_axis" string="z2"/>
|
||||
<field name="Z8_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div>上面:</div>
|
||||
<label for="X8_axis" string="x"/>
|
||||
<field name="X8_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y8_axis" string="y"/>
|
||||
<field name="Y8_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z8_axis" string="z"/>
|
||||
<field name="Z8_axis" class="o_form_label"/>
|
||||
</div>
|
||||
<div>上面:</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X9_axis" string="x"/>
|
||||
<field name="X9_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y9_axis" string="y"/>
|
||||
<field name="Y9_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z9_axis" string="z"/>
|
||||
<field name="Z9_axis" class="o_form_label"/>
|
||||
<div></div>
|
||||
<div class="o_address_format">
|
||||
<label for="X9_axis" string="x1"/>
|
||||
<field name="X9_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y9_axis" string="y1"/>
|
||||
<field name="Y9_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z9_axis" string="z1"/>
|
||||
<field name="Z9_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="o_address_format">
|
||||
<label for="X10_axis" string="x2"/>
|
||||
<field name="X10_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y10_axis" string="y2"/>
|
||||
<field name="Y10_axis" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z10_axis" string="z2"/>
|
||||
<field name="Z10_axis" class="o_address_zip"/>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"/>
|
||||
</div>
|
||||
</group>
|
||||
<label for="X10_axis" string="x"/>
|
||||
<field name="X10_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Y10_axis" string="y"/>
|
||||
<field name="Y10_axis" class="o_form_label"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="Z10_axis" string="z"/>
|
||||
<field name="Z10_axis" class="o_form_label"/>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="getcenter" string="计算定位"/>
|
||||
</div>
|
||||
|
||||
<group>
|
||||
<field name="material_center_point"/>
|
||||
<field name='X_deviation_angle'/>
|
||||
@@ -210,39 +197,43 @@
|
||||
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<field name="cnc_ids" widget="one2many">
|
||||
<tree>
|
||||
<field name="cnc_id"/>
|
||||
<field name="sequence_number"/>
|
||||
<field name="program_name"/>
|
||||
<field name="cutting_tool_name"/>
|
||||
<field name="cutting_tool_no"/>
|
||||
<field name="processing_type"/>
|
||||
<field name="margin_x_y"/>
|
||||
<field name="margin_z"/>
|
||||
<field name="depth_of_processing_z"/>
|
||||
<field name="cutting_tool_extension_length"/>
|
||||
<field name="cutting_tool_handle_type"/>
|
||||
<field name="estimated_processing_time"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序">
|
||||
<tree>
|
||||
<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"/>
|
||||
<field name="margin_x_y"/>
|
||||
<field name="margin_z"/>
|
||||
<field name="depth_of_processing_z"/>
|
||||
<field name="cutting_tool_extension_length"/>
|
||||
<field name="cutting_tool_handle_type"/>
|
||||
<field name="estimated_processing_time"/>
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="cnc_worksheet" string="工作指令" widget="pdf_viewer"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="selection"/>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<field name="test_results" widget="selection" />
|
||||
|
||||
</group>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
||||
string="检测确认"/>
|
||||
</div>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
||||
<group>
|
||||
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"/>
|
||||
</div>
|
||||
@@ -250,7 +241,7 @@
|
||||
<button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"
|
||||
string="打印标签"/>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user