From 0fb751ebbeff511915eb9cd94005f3e00fd334ff Mon Sep 17 00:00:00 2001 From: gqh Date: Tue, 25 Oct 2022 17:19:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=89=98=E7=9B=98=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=EF=BC=8C=E6=89=98=E7=9B=98=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/sf_common.py | 4 +- sf_base/views/mrs_common_view.xml | 24 ++++---- sf_route_workcenter/__init__.py | 2 + sf_route_workcenter/__manifest__.py | 25 ++++++++ sf_route_workcenter/models/__init__.py | 2 + sf_route_workcenter/models/workcenter.py | 70 ++++++++++++++++++++++ sf_route_workcenter/views/sf_tray_view.xml | 28 +++++++++ sf_route_workcenter/views/sf_workorder.xml | 21 +++++++ 8 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 sf_route_workcenter/__init__.py create mode 100644 sf_route_workcenter/__manifest__.py create mode 100644 sf_route_workcenter/models/__init__.py create mode 100644 sf_route_workcenter/models/workcenter.py create mode 100644 sf_route_workcenter/views/sf_tray_view.xml create mode 100644 sf_route_workcenter/views/sf_workorder.xml diff --git a/sf_base/models/sf_common.py b/sf_base/models/sf_common.py index 0d86e593..b1abf43b 100644 --- a/sf_base/models/sf_common.py +++ b/sf_base/models/sf_common.py @@ -72,9 +72,9 @@ class Tray(models.Model): _name = 'sf.tray' _description = '托盘' - code = fields.Char('编码') + code = fields.Char('编码',copy=False) name = fields.Char('名称') state = fields.Selection( [("空闲", "空闲"), ("占用", "占用"), ("报损", "报损")], - default=" ", string="状态") + default="空闲", string="状态") active = fields.Boolean('有效', default=True) diff --git a/sf_base/views/mrs_common_view.xml b/sf_base/views/mrs_common_view.xml index 1877de05..4f9374e1 100644 --- a/sf_base/views/mrs_common_view.xml +++ b/sf_base/views/mrs_common_view.xml @@ -281,14 +281,18 @@ sf.tray.search sf.tray - - - - - - - - + + + + + + + + + + + + @@ -308,11 +312,11 @@ sf.tray.form sf.tray +
- + - diff --git a/sf_route_workcenter/__init__.py b/sf_route_workcenter/__init__.py new file mode 100644 index 00000000..c081ee06 --- /dev/null +++ b/sf_route_workcenter/__init__.py @@ -0,0 +1,2 @@ +# -*-coding:utf-8-*- +from . import models diff --git a/sf_route_workcenter/__manifest__.py b/sf_route_workcenter/__manifest__.py new file mode 100644 index 00000000..8a4dffd0 --- /dev/null +++ b/sf_route_workcenter/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': '机企猫藏智能工厂 工序', + 'version': '1.0', + 'summary': '智能工厂工作中心工序', + 'sequence': 1, + 'description': """ +在本模块,同步资源库 + """, + 'category': 'YZ', + 'website': 'https://www.sf.cs.jikimo.com', + 'depends': ['mrp', 'sf_base'], + 'data': [ + 'views/sf_tray_view.xml', + 'views/sf_workorder.xml', + ], + 'demo': [ + ], + 'qweb': [ + ], + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/sf_route_workcenter/models/__init__.py b/sf_route_workcenter/models/__init__.py new file mode 100644 index 00000000..94d72e99 --- /dev/null +++ b/sf_route_workcenter/models/__init__.py @@ -0,0 +1,2 @@ +# -*-coding:utf-8-*- +from . import workcenter \ No newline at end of file diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py new file mode 100644 index 00000000..eae2f56c --- /dev/null +++ b/sf_route_workcenter/models/workcenter.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Part of SmartGo. See LICENSE file for full copyright and licensing details. +import base64 +import logging + +import qrcode + +from io import BytesIO +from odoo import api, fields, models +from odoo.exceptions import UserError + +_logger = logging.getLogger(__name__) + + +class Tray(models.Model): + _inherit = 'sf.tray' + _description = '托盘' + + production_id = fields.Many2one('mrp.production', string='制造订单', + related='workorder_id.production_id') + workorder_id = fields.Many2one('mrp.workorder', string="工单") + qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image') + + @api.depends('code') + def compute_qr_image(self): + for item in self: + if not item.code: + item.qr_image = False + continue + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + qr.add_data(item.code) + qr.make(fit=True) + img = qr.make_image() + temp = BytesIO() + img.save(temp, format='PNG') + qr_image = base64.b64encode(temp.getvalue()) + item.qr_image = qr_image + + +''' +工单绑定托盘信息 +''' + + +class MrpWorkOrder(models.Model): + _inherit = 'mrp.workorder' + _description = '工单' + + tray_id = fields.Many2one('sf.tray', string="托盘") + tray_code = fields.Char( + string='托盘编码', + related='tray_id.code') + tray_state = fields.Selection( + string='托盘状态', + related='tray_id.state') + + +''' +制造订单绑定托盘信息 +''' + + +class MrpProduction(models.Model): + _inherit = 'mrp.production' + _description = "制造订单" diff --git a/sf_route_workcenter/views/sf_tray_view.xml b/sf_route_workcenter/views/sf_tray_view.xml new file mode 100644 index 00000000..05cb382a --- /dev/null +++ b/sf_route_workcenter/views/sf_tray_view.xml @@ -0,0 +1,28 @@ + + + + 托盘二维码生成 + sf.tray + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sf_route_workcenter/views/sf_workorder.xml b/sf_route_workcenter/views/sf_workorder.xml new file mode 100644 index 00000000..c5b24711 --- /dev/null +++ b/sf_route_workcenter/views/sf_workorder.xml @@ -0,0 +1,21 @@ + + + + + 装夹工序工单 + mrp.workorder + + + + + + + + + + + + + + + \ No newline at end of file From ccb26bc4ec2aa4e329a60f8186a3fb51e286b818 Mon Sep 17 00:00:00 2001 From: gqh Date: Thu, 27 Oct 2022 17:24:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=89=98=E7=9B=98=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=87=BA=E6=9D=A1=E5=BD=A2=E7=A0=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_route_workcenter/__init__.py | 1 + sf_route_workcenter/__manifest__.py | 3 +- sf_route_workcenter/models/workcenter.py | 55 ++++++++++++++----- sf_route_workcenter/report/sf_tray_report.xml | 43 +++++++++++++++ sf_route_workcenter/views/sf_tray_view.xml | 27 +++------ 5 files changed, 97 insertions(+), 32 deletions(-) create mode 100644 sf_route_workcenter/report/sf_tray_report.xml diff --git a/sf_route_workcenter/__init__.py b/sf_route_workcenter/__init__.py index c081ee06..87c2fd17 100644 --- a/sf_route_workcenter/__init__.py +++ b/sf_route_workcenter/__init__.py @@ -1,2 +1,3 @@ # -*-coding:utf-8-*- from . import models +from . import report diff --git a/sf_route_workcenter/__manifest__.py b/sf_route_workcenter/__manifest__.py index 8a4dffd0..6cf239f2 100644 --- a/sf_route_workcenter/__manifest__.py +++ b/sf_route_workcenter/__manifest__.py @@ -10,10 +10,11 @@ """, 'category': 'YZ', 'website': 'https://www.sf.cs.jikimo.com', - 'depends': ['mrp', 'sf_base'], + 'depends': ['mrp', 'sf_base','hr_holidays'], 'data': [ 'views/sf_tray_view.xml', 'views/sf_workorder.xml', + 'report/sf_tray_report.xml' ], 'demo': [ ], diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py index eae2f56c..3551680e 100644 --- a/sf_route_workcenter/models/workcenter.py +++ b/sf_route_workcenter/models/workcenter.py @@ -7,6 +7,9 @@ import qrcode from io import BytesIO from odoo import api, fields, models +import barcode +from barcode.writer import ImageWriter +from pystrich.code128 import Code128Encoder from odoo.exceptions import UserError _logger = logging.getLogger(__name__) @@ -17,8 +20,8 @@ class Tray(models.Model): _description = '托盘' production_id = fields.Many2one('mrp.production', string='制造订单', - related='workorder_id.production_id') - workorder_id = fields.Many2one('mrp.workorder', string="工单") + ) + qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image') @api.depends('code') @@ -27,22 +30,31 @@ class Tray(models.Model): if not item.code: item.qr_image = False continue - qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=10, - border=4, - ) - qr.add_data(item.code) - qr.make(fit=True) - img = qr.make_image() + # 根据code动态生成二维码图片 + # qr = qrcode.QRCode( + # version=1, + # error_correction=qrcode.constants.ERROR_CORRECT_L, + # box_size=10, + # border=4, + # ) + # qr.add_data(item.code) + # qr.make(fit=True) + # img = qr.make_image() + # 生成条形码文件 + # bar = barcode.get("ean13", "123456789102", writer=ImageWriter()) + # a = bar.get_fullcode() + # b = bar.save('occ') + # 生成条形码图片 + partner_encoder = Code128Encoder(item.code) + # 转换bytes流 temp = BytesIO() - img.save(temp, format='PNG') + partner_encoder.save(temp) + # img.save(temp, format='PNG') qr_image = base64.b64encode(temp.getvalue()) item.qr_image = qr_image -''' +''' 工单绑定托盘信息 ''' @@ -58,6 +70,23 @@ class MrpWorkOrder(models.Model): tray_state = fields.Selection( string='托盘状态', related='tray_id.state') + # def get_tray_info(self): + + + @api.depends('tray_id') + def updateTrayState(self): + + for item in self: + if item.tray_code == False: + continue + trayInfo = self.env['sf.tray'].sudo.search([('code', '=', item.tray_code)]) + if trayInfo: + trayInfo.update( + { + 'production_id': item.production_id, + 'state': "占用", + } + ) ''' diff --git a/sf_route_workcenter/report/sf_tray_report.xml b/sf_route_workcenter/report/sf_tray_report.xml new file mode 100644 index 00000000..dcab9ee4 --- /dev/null +++ b/sf_route_workcenter/report/sf_tray_report.xml @@ -0,0 +1,43 @@ + + + + 打印条形码 + sf.tray + qweb-pdf + sf_route_workcenter.sf_tray_template + sf_route_workcenter.sf_tray_template + + report + + + + + + + European A4 for DIN5008 Type A + + A5 + Portrait + 27 + 40 + 20 + 10 + 70 + + 27 + + + diff --git a/sf_route_workcenter/views/sf_tray_view.xml b/sf_route_workcenter/views/sf_tray_view.xml index 05cb382a..f2d9f355 100644 --- a/sf_route_workcenter/views/sf_tray_view.xml +++ b/sf_route_workcenter/views/sf_tray_view.xml @@ -1,27 +1,18 @@ - 托盘二维码生成 + 托盘条形码生成 sf.tray - - - - - - - - - - - - - - - - - + + + + + + + + From d3757871606554f87107ac51724d2a756a50f126 Mon Sep 17 00:00:00 2001 From: gqh Date: Mon, 31 Oct 2022 17:32:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=89=98=E7=9B=98=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=BB=91=E5=AE=9A=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=89=98=E7=9B=98=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20=E6=B7=BB=E5=8A=A0=E8=A7=A3=E9=99=A4=E8=A3=85?= =?UTF-8?q?=E5=A4=B9=E5=8A=9F=E8=83=BD=20=E4=B8=89=E5=85=83=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E5=A2=9E=E5=8A=A0xy=208=E4=B8=AA=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_route_workcenter/models/workcenter.py | 70 +++++++++++++++---- sf_route_workcenter/report/sf_tray_report.xml | 39 ++++++----- sf_route_workcenter/views/sf_tray_view.xml | 12 +++- sf_route_workcenter/views/sf_workorder.xml | 70 ++++++++++++++++++- 4 files changed, 159 insertions(+), 32 deletions(-) diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py index 3551680e..feccccb4 100644 --- a/sf_route_workcenter/models/workcenter.py +++ b/sf_route_workcenter/models/workcenter.py @@ -18,11 +18,26 @@ _logger = logging.getLogger(__name__) class Tray(models.Model): _inherit = 'sf.tray' _description = '托盘' + qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image') production_id = fields.Many2one('mrp.production', string='制造订单', + related='workorder_id.production_id' ) + workorder_id = fields.Many2one('mrp.workorder', string="工单" + ) - qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image') + @api.onchange('production_id') + def updateTrayState(self): + + if self.workorder_id != False: + self.state = '占用' + else: + self.state = '空闲' + + def unclamp(self): + self.workorder_id = False + self.production_id = False + self.state = '空闲' @api.depends('code') def compute_qr_image(self): @@ -70,23 +85,48 @@ class MrpWorkOrder(models.Model): tray_state = fields.Selection( string='托盘状态', related='tray_id.state') + # def get_tray_info(self): + @api.onchange('X_axis', 'Y_axis', 'Z_axis') + def get_center_point(self): + return 'X:%s,Y:%s,Z:%s' % (self.X_axis, self.Y_axis, self.Z_axis) + surface = fields.Selection([("上面", "上面"), ("下面", "下面"), ("左面", "左面"), ("右面", "右面"), + ("顶面", "顶面")], required=True, default="顶面") + material_center_point = fields.Char(string='配料中心点', default=get_center_point) + X1_axis = fields.Integer(string='x1', default=0) + Y1_axis = fields.Integer(string='y1', default=0) + X2_axis = fields.Integer(string='x2', default=0) + Y2_axis = fields.Integer(string='y2', default=0) + X3_axis = fields.Integer(string='x3', default=0) + Y3_axis = fields.Integer(string='y3', default=0) + X4_axis = fields.Integer(string='x4', default=0) + Y4_axis = fields.Integer(string='y4', default=0) + X5_axis = fields.Integer(string='x5', default=0) + Y5_axis = fields.Integer(string='y5', default=0) + X6_axis = fields.Integer(string='x6', default=0) + Y6_axis = fields.Integer(string='y6', default=0) + X7_axis = fields.Integer(string='x7', default=0) + Y7_axis = fields.Integer(string='y7', default=0) + X8_axis = fields.Integer(string='x8', default=0) + Y8_axis = fields.Integer(string='y8', default=0) - @api.depends('tray_id') - def updateTrayState(self): + X_deviation_angle = fields.Integer(string="X轴偏差度", default=0) - for item in self: - if item.tray_code == False: - continue - trayInfo = self.env['sf.tray'].sudo.search([('code', '=', item.tray_code)]) - if trayInfo: - trayInfo.update( - { - 'production_id': item.production_id, - 'state': "占用", - } - ) + # @api.depends('tray_id') + # def updateTrayState(self): + # + # for item in self: + # if item.tray_code == False: + # continue + # trayInfo = self.env['sf.tray'].sudo.search([('code', '=', item.tray_code)]) + # if trayInfo: + # trayInfo.update( + # { + # 'production_id': item.production_id, + # 'state': "占用", + # } + # ) ''' @@ -97,3 +137,5 @@ class MrpWorkOrder(models.Model): class MrpProduction(models.Model): _inherit = 'mrp.production' _description = "制造订单" + + tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘") diff --git a/sf_route_workcenter/report/sf_tray_report.xml b/sf_route_workcenter/report/sf_tray_report.xml index dcab9ee4..d1af6676 100644 --- a/sf_route_workcenter/report/sf_tray_report.xml +++ b/sf_route_workcenter/report/sf_tray_report.xml @@ -1,5 +1,21 @@ + + + Dymo Label Sheet + + custom + 100 + 60 + Landscape + 0 + 0 + 0 + 0 + + 96 + + 打印条形码 sf.tray @@ -8,7 +24,7 @@ sf_route_workcenter.sf_tray_template report - + @@ -17,27 +33,18 @@
-

编码:

-
+
+
+ - - European A4 for DIN5008 Type A - - A5 - Portrait - 27 - 40 - 20 - 10 - 70 - - 27 - + + diff --git a/sf_route_workcenter/views/sf_tray_view.xml b/sf_route_workcenter/views/sf_tray_view.xml index f2d9f355..c9520f63 100644 --- a/sf_route_workcenter/views/sf_tray_view.xml +++ b/sf_route_workcenter/views/sf_tray_view.xml @@ -9,8 +9,18 @@ - + + + + +
+
+
+
diff --git a/sf_route_workcenter/views/sf_workorder.xml b/sf_route_workcenter/views/sf_workorder.xml index c5b24711..a12db9f0 100644 --- a/sf_route_workcenter/views/sf_workorder.xml +++ b/sf_route_workcenter/views/sf_workorder.xml @@ -6,7 +6,7 @@ mrp.workorder - + @@ -14,7 +14,75 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
From 3dfbd7a1e459e59797b6c829c46fe162dc4c9c91 Mon Sep 17 00:00:00 2001 From: gqh Date: Thu, 3 Nov 2022 15:09:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/sf_base.py | 17 ++ sf_base/security/ir.model.access.csv | 1 + sf_route_workcenter/models/workcenter.py | 110 +++++++++--- sf_route_workcenter/views/sf_workorder.xml | 199 ++++++++++++++------- 4 files changed, 240 insertions(+), 87 deletions(-) diff --git a/sf_base/models/sf_base.py b/sf_base/models/sf_base.py index 453f6eb0..d10f190e 100644 --- a/sf_base/models/sf_base.py +++ b/sf_base/models/sf_base.py @@ -247,3 +247,20 @@ class CuttingToolType(models.Model): brand_id = fields.Many2one('mrs.machine.brand', string='品牌') remark = fields.Text('备注') active = fields.Boolean('有效', default=True) + +class CNCprocessing(models.Model): + _name = 'cnc.processing' + _description = "CNC加工" + + FNo = fields.Char(string="序号") + FPGName = fields.Char(string="程序名") + FKnifeName = fields.Char(string="刀具名称") + FDNo = fields.Char(string="刀号") + FWorkType = fields.Char(string="加工类型") + FXY = fields.Char(string="余量_X/Y") + FZ = fields.Char(string="余量_Z") + FJGSD = fields.Char(string="加工深度(Z)") + FSCCD = fields.Char(string="刀具伸出长度") + FDJSpec = fields.Char(string="刀柄型号") + FJGDate = fields.Char(string="预计加工时间") + FComment = fields.Char(string="备注") diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 5b4aa249..930fcd07 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -13,6 +13,7 @@ access_mrs_production_materials,mrs_production_materials,model_mrs_production_ma access_mrs_materials_model,mrs_materials_model,model_mrs_materials_model,base.group_user,1,1,1,1 access_mrs_processing_technology,mrs_processing_technology,model_mrs_processing_technology,base.group_user,1,1,1,1 access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1 +access_cnc_processing,cnc_processing,model_cnc_processing,base.group_user,1,1,1,1 diff --git a/sf_route_workcenter/models/workcenter.py b/sf_route_workcenter/models/workcenter.py index feccccb4..4340b465 100644 --- a/sf_route_workcenter/models/workcenter.py +++ b/sf_route_workcenter/models/workcenter.py @@ -2,6 +2,7 @@ # Part of SmartGo. See LICENSE file for full copyright and licensing details. import base64 import logging +import math import qrcode @@ -15,6 +16,13 @@ from odoo.exceptions import UserError _logger = logging.getLogger(__name__) +class CNCprocessing(models.Model): + _inherit = 'cnc.processing' + _description = "CNC加工" + + workorder_id = fields.Many2one('mrp.workorder' ,string="工单") + + class Tray(models.Model): _inherit = 'sf.tray' _description = '托盘' @@ -87,32 +95,90 @@ class MrpWorkOrder(models.Model): related='tray_id.state') # def get_tray_info(self): - @api.onchange('X_axis', 'Y_axis', 'Z_axis') - def get_center_point(self): - return 'X:%s,Y:%s,Z:%s' % (self.X_axis, self.Y_axis, self.Z_axis) + # @api.onchange('X_axis', 'Y_axis', 'Z_axis') + # def get_center_point(self): + # return 'X:%s,Y:%s,Z:%s' % (self.X_axis, self.Y_axis, self.Z_axis) + # 加工面 + surface = fields.Selection([("前面", "前面"), ("后面", "后面"), ("左面", "左面"), ("右面", "右面"), + ("上面", "上面")], required=True, default="顶面", string="加工面") + material_center_point = fields.Char(string='配料中心点') + X1_axis = fields.Float(string='Lx1', default=0) + Y1_axis = fields.Float(string='Ly1', default=0) + Z1_axis = fields.Float(string='Lz1', default=0) + X2_axis = fields.Float(string='Lx2', default=0) + Y2_axis = fields.Float(string='Ly2', default=0) + Z2_axis = fields.Float(string='Lz2', default=0) + X3_axis = fields.Float(string='Fx3', default=0) + Y3_axis = fields.Float(string='Fy3', default=0) + Z3_axis = fields.Float(string='Fz3', default=0) + X4_axis = fields.Float(string='Fx4', default=0) + Y4_axis = fields.Float(string='Fy4', default=0) + Z4_axis = fields.Float(string='Fz4', default=0) + X5_axis = fields.Float(string='Rx5', default=0) + Y5_axis = fields.Float(string='Ry5', default=0) + Z5_axis = fields.Float(string='Rz5', default=0) + X6_axis = fields.Float(string='Rx6', default=0) + Y6_axis = fields.Float(string='Ry6', default=0) + Z6_axis = fields.Float(string='Rz6', default=0) + X7_axis = fields.Float(string='Bx7', default=0) + Y7_axis = fields.Float(string='By7', default=0) + Z7_axis = fields.Float(string='Bz7', default=0) + X8_axis = fields.Float(string='Bx8', default=0) + Y8_axis = fields.Float(string='By8', default=0) + Z8_axis = fields.Float(string='Bz8', default=0) + X9_axis = fields.Float(string='Uz9', default=0) + Y9_axis = fields.Float(string='Uz9', default=0) + Z9_axis = fields.Float(string='Uz9', default=0) + X10_axis = fields.Float(string='Uz10', default=0) + Y10_axis = fields.Float(string='Uz10', default=0) + Z10_axis = fields.Float(string='Uz10', default=0) - surface = fields.Selection([("上面", "上面"), ("下面", "下面"), ("左面", "左面"), ("右面", "右面"), - ("顶面", "顶面")], required=True, default="顶面") - material_center_point = fields.Char(string='配料中心点', default=get_center_point) - X1_axis = fields.Integer(string='x1', default=0) - Y1_axis = fields.Integer(string='y1', default=0) - X2_axis = fields.Integer(string='x2', default=0) - Y2_axis = fields.Integer(string='y2', default=0) - X3_axis = fields.Integer(string='x3', default=0) - Y3_axis = fields.Integer(string='y3', default=0) - X4_axis = fields.Integer(string='x4', default=0) - Y4_axis = fields.Integer(string='y4', default=0) - X5_axis = fields.Integer(string='x5', default=0) - Y5_axis = fields.Integer(string='y5', default=0) - X6_axis = fields.Integer(string='x6', default=0) - Y6_axis = fields.Integer(string='y6', default=0) - X7_axis = fields.Integer(string='x7', default=0) - Y7_axis = fields.Integer(string='y7', default=0) - X8_axis = fields.Integer(string='x8', default=0) - Y8_axis = fields.Integer(string='y8', default=0) + # 扫码绑定托盘方法 + def gettray(self): + return "" + + # 计算配料中心点和与x轴倾斜度方法 + def getcenter(self): + x1 = self.X1_axis + x2 = self.X2_axis + x3 = self.X3_axis + x4 = self.X4_axis + x5 = self.X5_axis + x6 = self.X6_axis + x7 = self.X7_axis + x8 = self.X8_axis + y1 = self.Y1_axis + y2 = self.Y2_axis + y3 = self.Y3_axis + y4 = self.Y4_axis + y5 = self.Y5_axis + y6 = self.Y6_axis + y7 = self.Y7_axis + y8 = self.Y8_axis + z1 = self.Z9_axis + x0 = ((x3 - x4) * (x2 * y1 - x1 * y2) - (x1 - x2) * (x4 * y3 - x3 * y4)) / ( + (x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4)) + y0 = ((y3 - y4) * (y2 * x1 - y1 * x2) - (y1 - y2) * (y4 * x3 - y3 * x4)) / ( + (y3 - y4) * (x1 - x2) - (y1 - y2) * (x3 - x4)) + x1 = ((x7 - x8) * (x6 * y5 - x5 * y7) - (x5 - x6) * (x8 * y7 - x7 * y8)) / ( + (x7 - x8) * (y5 - y6) - (x5 - x6) * (y7 - y8)); + y1 = ((y7 - y8) * (y6 * x5 - y5 * x7) - (y5 - y6) * (y8 * x7 - y7 * x8)) / ( + (y7 - y8) * (x5 - x6) - (y5 - y6) * (x7 - x8)) + x = (x0 + x1) / 2 + y = (y0 + y1) / 2 + z = z1 / 2 + + jd = math.atan2((x7 - x8), (y7 - y8)) + jdz = jd * 180 / math.pi + print("(%s,%s)" % (x, y)) + self.material_center_point = ("(%s,%s,%s)" % (x, y, z)) + self.X_deviation_angle = jdz X_deviation_angle = fields.Integer(string="X轴偏差度", default=0) + test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果") + + cnc_ids = fields.One2many("cnc.processing",'workorder_id', string="CNC加工") # @api.depends('tray_id') # def updateTrayState(self): # diff --git a/sf_route_workcenter/views/sf_workorder.xml b/sf_route_workcenter/views/sf_workorder.xml index a12db9f0..daa77756 100644 --- a/sf_route_workcenter/views/sf_workorder.xml +++ b/sf_route_workcenter/views/sf_workorder.xml @@ -6,82 +6,151 @@ mrp.workorder - - + + - - - + +
+
-
- + + - + - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ +
+ + + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+ + +
+ + + + +
-
+
+ + + + + + + + + + + + + + + + + + + +