优化agv需求
This commit is contained in:
@@ -486,7 +486,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
return [
|
||||
[0, '', {'production_id': production.id, 'type': '上产线', 'delivery_num': '%s-%s' % (production.name, 1)}],
|
||||
[0, '',
|
||||
{'production_id': production.id, 'type': '下产线', 'delivery_num': '%s-%s' % (production.name, 2)}], ]
|
||||
{'production_id': production.id, 'type': '下产线', 'delivery_num': '%s-%s' % (production.name, 2)}]]
|
||||
|
||||
# 拼接工单对象属性值(表面工艺)
|
||||
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
||||
@@ -1095,9 +1095,12 @@ class WorkPieceDelivery(models.Model):
|
||||
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
|
||||
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
|
||||
status = fields.Selection(
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', )
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
|
||||
@api.onchange('route_id')
|
||||
def onchange_route(self):
|
||||
if self.route_id:
|
||||
@@ -1113,7 +1116,7 @@ class WorkPieceDelivery(models.Model):
|
||||
same_production_line_id = None
|
||||
same_route_id = None
|
||||
down_status = '待下发'
|
||||
production_type = '上产线'
|
||||
production_type = None
|
||||
num = 0
|
||||
for item in self:
|
||||
num += 1
|
||||
@@ -1126,8 +1129,10 @@ class WorkPieceDelivery(models.Model):
|
||||
is_not_route += 1
|
||||
else:
|
||||
raise UserError('请选择【任务路线】再进行配送')
|
||||
# if production_type != item.type:
|
||||
# raise UserError('请选择类型为【上产线】的制造订单进行配送')
|
||||
if production_type is None:
|
||||
production_type = item.type
|
||||
if production_type != item.type:
|
||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||
if down_status != item.status:
|
||||
raise UserError('请选择状态为【待下发】的制造订单进行配送')
|
||||
if same_production_line_id is None:
|
||||
@@ -1144,23 +1149,40 @@ class WorkPieceDelivery(models.Model):
|
||||
raise UserError('您所选择制造订单的【目的生产线】不一致,请重新确认')
|
||||
if is_not_route >= 1:
|
||||
raise UserError('您所选择制造订单的【任务路线】不一致,请重新确认')
|
||||
if delivery_ids:
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
}}
|
||||
is_free = self._check_avgsite_state()
|
||||
if is_free is True:
|
||||
if delivery_ids:
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
}}
|
||||
else:
|
||||
raise UserError("您所选择制造订单的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时进行配送")
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
# 验证agv站点是否可用
|
||||
def _check_avgsite_state(self):
|
||||
is_free = False
|
||||
agv_site = self.env['sf.agv.site'].search([])
|
||||
if agv_site:
|
||||
agv_site.update_site_state()
|
||||
# if
|
||||
for item in self:
|
||||
if item.type in ["上产线", "下产线"]:
|
||||
logging.info('工件配送-起点状态:%s-%s' % (
|
||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||
logging.info('工件配送-终点状态:%s-%s' % (
|
||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||
if item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲':
|
||||
is_free = True
|
||||
logging.info('is_free:%s' % is_free)
|
||||
return is_free
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
positionCode_Arr = []
|
||||
delivery_Arr = []
|
||||
@@ -1172,7 +1194,7 @@ class WorkPieceDelivery(models.Model):
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
delivery_Arr.append(item.delivery_num)
|
||||
delivery_str = ', '.join(map(str, delivery_Arr))
|
||||
delivery_str = ','.join(map(str, delivery_Arr))
|
||||
if feeder_station_start is not None:
|
||||
positionCode_Arr.append({
|
||||
'positionCode': feeder_station_start,
|
||||
|
||||
Reference in New Issue
Block a user