新增工单字段
This commit is contained in:
@@ -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):
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user