From d3757871606554f87107ac51724d2a756a50f126 Mon Sep 17 00:00:00 2001 From: gqh Date: Mon, 31 Oct 2022 17:32:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=98=E7=9B=98=E6=A0=B9=E6=8D=AE=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=BB=91=E5=AE=9A=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=89=98=E7=9B=98=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E8=A7=A3=E9=99=A4=E8=A3=85=E5=A4=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E4=B8=89=E5=85=83=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0xy=208=E4=B8=AA=E7=82=B9=E7=9A=84=E5=AD=97?= =?UTF-8?q?=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 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+