diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 1c49c88b..54538a7d 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -13,6 +13,7 @@ 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse'], 'data': [ 'data/stock_data.xml', + 'data/empty_racks_data.xml', 'security/group_security.xml', 'security/ir.model.access.csv', 'wizard/workpiece_delivery_views.xml', diff --git a/sf_manufacturing/controllers/workpiece.py b/sf_manufacturing/controllers/workpiece.py index 8cda129b..5c5d6f22 100644 --- a/sf_manufacturing/controllers/workpiece.py +++ b/sf_manufacturing/controllers/workpiece.py @@ -28,7 +28,7 @@ class Workpiece(http.Controller): req_codes = ret['reqCode'].split(',') for req_code in req_codes: workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('delivery_num', '=', req_code.strip()), ('task_completion_time', '=', False)]) + [('name', '=', req_code.strip()), ('task_completion_time', '=', False)]) if workpiece_delivery: workpiece_delivery.write({'status': '已配送', 'task_completion_time': datetime.now()}) else: diff --git a/sf_manufacturing/data/empty_racks_data.xml b/sf_manufacturing/data/empty_racks_data.xml index 90102ec2..e30edd9f 100644 --- a/sf_manufacturing/data/empty_racks_data.xml +++ b/sf_manufacturing/data/empty_racks_data.xml @@ -1,36 +1,48 @@ - - + + + 工件配送 + sf.workpiece.delivery + WDO%(year)s%(month)s%(day)s + 4 + + + + 运送空料架路线:C01-A01 - sf.workpiece.delivery - WCA%(year)s%(month)s%(day)s - 4 - + 运送空料架 + + + - + 运送空料架路线:B01-B02 - sf.workpiece.delivery - WBB%(year)s%(month)s%(day)s - 4 - + 运送空料架 + + + - + 运送空料架路线:B01-A01 - sf.workpiece.delivery - WBA%(year)s%(month)s%(day)s - 4 - + 运送空料架 + + + - + 运送空料架路线:C01-B02 - sf.workpiece.delivery - WCB%(year)s%(month)s%(day)s - 4 - + 运送空料架 + + + \ No newline at end of file diff --git a/sf_manufacturing/models/agv_setting.py b/sf_manufacturing/models/agv_setting.py index 164d3175..efdde900 100644 --- a/sf_manufacturing/models/agv_setting.py +++ b/sf_manufacturing/models/agv_setting.py @@ -46,11 +46,4 @@ class AgvTaskRoute(models.Model): start_site_id = fields.Many2one('sf.agv.site', '起点接驳站位置编号') end_site_id = fields.Many2one('sf.agv.site', '终点接驳站位置编号') destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线') - priority = fields.Selection([ - ('0', '正常'), - ('1', '低'), - ('2', '中'), - ('3', '高'), - ('4', '紧急'), - ], string='优先级', default='0') active = fields.Boolean('有效', default=True) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 70551c5e..3e0d5671 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -484,9 +484,8 @@ class ResMrpWorkOrder(models.Model): def _json_workpiece_delivery_list(self, production): 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)}]] + [0, '', {'production_id': production.id, 'type': '上产线'}], + [0, '', {'production_id': production.id, 'type': '下产线'}]] # 拼接工单对象属性值(表面工艺) def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id): @@ -770,7 +769,7 @@ class ResMrpWorkOrder(models.Model): raise UserError("请对前置三元检测定位参数进行计算定位") if not self.rfid_code: raise UserError("请扫RFID码进行绑定") - self.workpiece_delivery_ids[0].write({'status': '待下发'}) + # self.workpiece_delivery_ids[0].write({'status': '待下发'}) if self.picking_out_id: picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) if picking_out.workorder_out_id: @@ -1078,8 +1077,7 @@ class WorkPieceDelivery(models.Model): _name = "sf.workpiece.delivery" _description = '工件配送' - name = fields.Char('名称') - delivery_num = fields.Char('工件配送编码') + name = fields.Char('单据编号') workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True) production_id = fields.Many2one('mrp.production', string='制造订单号', readonly=True) production_line_id = fields.Many2one('sf.production.line', string='目的生产线') @@ -1098,8 +1096,22 @@ class WorkPieceDelivery(models.Model): is_cnc_program_down = fields.Boolean('程序是否下发', default=False) active = fields.Boolean(string="有效", default=True) - # @api.model - # def create(self, vals): + @api.model + def create(self, vals): + if vals.get('name', '/') == '/' or vals.get('name', '/') is False: + vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/' + obj = super(WorkPieceDelivery, self).create(vals) + return obj + + def action_delivery_history(self): + return { + 'name': _('配送历史'), + 'type': 'ir.actions.act_window', + 'view_mode': 'tree', + 'res_model': 'sf.workpiece.delivery', + 'view_id': self.env.ref('sf_manufacturing.sf_workpiece_delivery_empty_racks_tree').id, + 'domain': [('type', '=', '运送空料架'), ('route_id', '=', self.route_id.id), ('name', 'ilike', 'WDO')] + } @api.onchange('route_id') def onchange_route(self): @@ -1120,29 +1132,37 @@ class WorkPieceDelivery(models.Model): num = 0 for item in self: num += 1 - if num > 4: - raise UserError('仅限于配送1-4个制造订单,请重新选择') - if item.route_id: - if same_route_id is None: - same_route_id = item.route_id.id - if item.route_id.id != same_route_id: - is_not_route += 1 + if item.type == "运送空料架": + if num >= 2: + raise UserError('仅选择一条路线进行配送,请重新选择') + else: + delivery_ids.append(item.id) else: - 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: - same_production_line_id = item.production_line_id.id - if item.production_line_id.id != same_production_line_id: - is_not_production_line += 1 - if item.is_cnc_program_down is False: - is_cnc_down += 1 - if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0: - delivery_ids.append(item.id) + if num > 4: + raise UserError('仅限于配送1-4个制造订单,请重新选择') + if item.status in ['待配送', '已配送']: + raise UserError('请选择状态为【待下发】的制造订单进行配送') + if item.route_id: + if same_route_id is None: + same_route_id = item.route_id.id + if item.route_id.id != same_route_id: + is_not_route += 1 + else: + 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: + same_production_line_id = item.production_line_id.id + if item.production_line_id.id != same_production_line_id: + is_not_production_line += 1 + if item.is_cnc_program_down is False: + is_cnc_down += 1 + if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0: + delivery_ids.append(item.id) if is_cnc_down >= 1: raise UserError('您所选择制造订单的【CNC程序】暂未下发,请在程序下发后再进行配送') if is_not_production_line >= 1: @@ -1162,7 +1182,11 @@ class WorkPieceDelivery(models.Model): 'default_delivery_ids': [(6, 0, delivery_ids)], }} else: - raise UserError("您所选择制造订单的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时进行配送") + if self.type == '运送空料架': + raise UserError("您所选择的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时进行配送") + else: + raise UserError( + "您所选择制造订单的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时或选择其他路线进行配送") # 验证agv站点是否可用 def _check_avgsite_state(self): @@ -1171,21 +1195,29 @@ class WorkPieceDelivery(models.Model): if agv_site: agv_site.update_site_state() 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)) + 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.type in ['上产线', '下产线']: if ( item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or ( item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'): is_free = True + else: + if 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() + if self.type == '运送空料架': + self = self.create( + {'name': self.env['ir.sequence'].next_by_code('sf.workpiece.delivery'), 'route_id': self.route_id.id, + 'feeder_station_start_id': self.feeder_station_start_id.id, + 'feeder_station_destination_id': self.feeder_station_destination_id.id}) positionCode_Arr = [] delivery_Arr = [] feeder_station_start = None @@ -1195,7 +1227,7 @@ class WorkPieceDelivery(models.Model): feeder_station_start = item.feeder_station_start_id.name if feeder_station_destination is None: feeder_station_destination = item.feeder_station_destination_id.name - delivery_Arr.append(item.delivery_num) + delivery_Arr.append(item.name) delivery_str = ','.join(map(str, delivery_Arr)) if feeder_station_start is not None: positionCode_Arr.append({ @@ -1224,13 +1256,14 @@ class WorkPieceDelivery(models.Model): req_codes = ret['reqCode'].split(',') for delivery_item in self: for req_code in req_codes: - if delivery_item.delivery_num == req_code.strip(): - logging.info('delivery_num:%s' % delivery_item.delivery_num) + if delivery_item.name == req_code.strip(): + logging.info('delivery_item-name:%s' % delivery_item.name) delivery_item.write({ 'task_delivery_time': fields.Datetime.now(), 'status': '待配送' }) - delivery_item.workorder_id.write({'is_delivery': True}) + if delivery_item == "上产线": + delivery_item.workorder_id.write({'is_delivery': True}) else: raise UserError(ret['message']) except Exception as e: diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 28b06aeb..87f262c0 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -591,8 +591,7 @@ decoration-warning="status == '待下发'" decoration-danger="status == '待配送'"/> - - + @@ -644,45 +643,42 @@ - 运送空料架 + 空料架配送 sf.workpiece.delivery - +
+ - - + + +