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 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+