托盘根据工单绑定制造订单,修改托盘状态
添加解除装夹功能 三元定位增加xy 8个点的字段
This commit is contained in:
@@ -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="托盘")
|
||||
|
||||
Reference in New Issue
Block a user