diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 9a7c949d..f65897d7 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -103,7 +103,11 @@ class ResMrpWorkOrder(models.Model): record.back_button_display = True else: record.back_button_display = False - if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹': + # tag_type + if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹' or any( + detection_result.processing_panel == cur_workorder.processing_panel and detection_result.routing_type == cur_workorder.routing_type and cur_workorder.tag_type !='重新加工' + for detection_result in cur_workorder.production_id.detection_result_ids + ): record.back_button_display = False else: next_workorder = sorted_workorders[position + 1] @@ -113,7 +117,10 @@ class ResMrpWorkOrder(models.Model): record.back_button_display = True else: record.back_button_display = False - if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹': + if cur_workorder.is_subcontract or cur_workorder.name == '解除装夹' or any( + detection_result.processing_panel == cur_workorder.processing_panel and detection_result.routing_type == cur_workorder.routing_type and cur_workorder.tag_type !='重新加工' + for detection_result in cur_workorder.production_id.detection_result_ids + ): record.back_button_display = False date_planned_start = fields.Datetime(tracking=True) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 96a35221..06ceb739 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -646,6 +646,16 @@ class StockPicking(models.Model): stock_picking = stock_picking_list.filtered(lambda p: p.state not in ("done", "cancel")) if sale_id and not stock_picking: sale_id.write({'state': 'delivered'}) + if self.location_dest_id.name == '成品存货区' and self.state == 'done': + for move in self.move_ids: + for production in self.sale_order_id.mrp_production_ids: + moves = self.env['stock.move'].search([ + ('name', '=', production.name), + ('state', '!=', 'cancel') + ]) + finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None) + if finish_move.id in move.move_orig_ids.ids and finish_move.state == 'done': + production.workorder_ids.write({'back_button_display': False}) return res # 创建 外协出库入单 diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index bd94e9c9..ff6b0a20 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -202,10 +202,11 @@ attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>