From 9eddfe36d6f48326e75942ab8a72149670a54407 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 25 Jul 2024 15:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=94=E5=B7=A5-=E5=B7=A5?= =?UTF-8?q?=E4=BB=B6=E9=85=8D=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 11 ++++++++--- sf_manufacturing/models/mrp_production.py | 3 ++- sf_manufacturing/models/mrp_workorder.py | 3 ++- sf_manufacturing/views/mrp_workorder_view.xml | 9 ++++++--- sf_manufacturing/wizard/rework_wizard.py | 8 +++++++- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 005e3717..f5a55db2 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -486,7 +486,9 @@ class Manufacturing_Connect(http.Controller): workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [ ('rfid_code', '=', rfid_code), ('type', '=', '上产线'), - ('production_id', '=', order.production_id.id)]) + ('production_id', '=', order.production_id.id), + ('workorder_id', '=', order.id), + ('workorder_state', '=', 'done')]) if workpiece_delivery.status == '待下发': workpiece_delivery.write({'is_manual_work': True}) else: @@ -548,8 +550,11 @@ class Manufacturing_Connect(http.Controller): workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [ ('rfid_code', '=', rfid_code), ('type', '=', '下产线'), - ('production_id', '=', order.production_id.id)]) - delivery_Arr.append(workpiece_delivery.id) + ('production_id', '=', order.production_id.id), + ('workorder_id', '=', order.id), + ('workorder_state', '=', 'done')]) + if workpiece_delivery: + delivery_Arr.append(workpiece_delivery.id) else: res = {'Succeed': False, 'ErrorCode': 204, 'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']} diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ef470678..65c3ebec 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -734,7 +734,7 @@ class MrpProduction(models.Model): for production in self: logging.info('qty_produced:%s' % production.qty_produced) - if production.qty_produced == '0.0': + if production.qty_produced == 0.0: production.qty_produced = 1.0 production.write({ 'date_finished': fields.Datetime.now(), @@ -897,6 +897,7 @@ class MrpProduction(models.Model): result), 'cmm_ids': panel_workorder.cmm_ids.sudo()._json_cmm_program(processing_panel, result), 'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + logging.info('len(cnc_worksheet):%s' % len(panel_workorder.cnc_worksheet)) pre_workorder = production.workorder_ids.filtered(lambda ap: ap.routing_type == '装夹预调' and ap.processing_panel == processing_panel and ap.state not in ( 'rework', 'done')) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 8781755d..a2745150 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1404,7 +1404,8 @@ class WorkPieceDelivery(models.Model): [('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型') delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( - [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发', + [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送'), ('已取消', '已取消')], string='状态', + default='待下发', tracking=True) is_cnc_program_down = fields.Boolean('程序是否下发', default=False, tracking=True) is_manual_work = fields.Boolean('人工操作', default=False) diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 0f5a656e..805dcb1f 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -475,7 +475,8 @@ + decoration-danger="status == '待配送'" + decoration-info="status== '已取消'"/> @@ -635,7 +636,9 @@ + decoration-danger="status == '待配送'" + decoration-info="status == '已取消'" + /> @@ -731,7 +734,7 @@ tree,form - [('type','in',['上产线','下产线']),('workorder_state','=','done'),('is_manual_work','=',false)] + [('type','in',['上产线','下产线']),('workorder_state','in',['done','rework']),('is_manual_work','=',false)] diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index c50e267d..f15f85d1 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -69,6 +69,12 @@ class ReworkWizard(models.TransientModel): lambda ap: ap.processing_panel == panel.name and ap.state != 'rework') if panel_workorder: panel_workorder.write({'state': 'rework'}) + panel_workorder.filtered( + lambda wo: wo.routing_type == '装夹预调').workpiece_delivery_ids.filtered( + lambda wd: wd.status == '待下发').write({'status': '已取消'}) + # workpiece = self.env['sf.workpiece.delivery'].search([('status', '=', '待下发'), ( + # 'workorder_id', '=', + # panel_workorder.filtered(lambda wd: wd.routing_type == '装夹预调').id)]) product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search( [('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)], order='sequence asc' @@ -137,7 +143,7 @@ class ReworkWizard(models.TransientModel): ret), 'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name, ret), - 'cnc_worksheet': new_cnc_workorder.cnc_worksheet}) + 'cnc_worksheet': cnc_rework.cnc_worksheet}) new_pre_workorder = self.production_id.workorder_ids.filtered(lambda p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in ( 'rework', 'done'))