制造订单工序自动生成规则

This commit is contained in:
gqh
2022-11-16 17:35:42 +08:00
parent 4ce0a7670c
commit 4f0df9f2bd
4 changed files with 171 additions and 61 deletions

View File

@@ -5,7 +5,7 @@ import logging
import math
from io import BytesIO
from odoo import api, fields, models, SUPERUSER_ID
from odoo import api, fields, models, SUPERUSER_ID, _
from pystrich.code128 import Code128Encoder
from odoo.exceptions import ValidationError
@@ -146,18 +146,18 @@ class MrpWorkOrder(models.Model):
(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)) / (
x1 = ((x7 - x8) * (x6 * y5 - x5 * y6) - (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)) / (
y1 = ((y7 - y8) * (y6 * x5 - y5 * x6) - (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))
jd = math.atan2((x5 - x6), (y5 - y6))
jdz = jd * 180 / math.pi
print("(%s,%s)" % (x, y))
self.material_center_point = ("(%s,%s,%s)" % (x, y, z))
print("(%.2f,%.2f)" % (x, y))
self.material_center_point = ("(%.2f,%.2f,%.2f)" % (x, y, z))
self.X_deviation_angle = jdz
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
@@ -185,8 +185,8 @@ class MrpWorkOrder(models.Model):
})
else:
raise ValidationError('该托盘编码已失效')
else:return ""
else:
return ""
# 解除托盘绑定
def unbindtray(self):