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')]}"/>
-
-
-
-
+
+
+
+
diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py
index 0415d1fd..66d7ea8d 100644
--- a/sf_manufacturing/wizard/production_technology_wizard.py
+++ b/sf_manufacturing/wizard/production_technology_wizard.py
@@ -3,6 +3,7 @@
import logging
from itertools import groupby
from odoo import models, api, fields, _
+from odoo.exceptions import UserError
class ProductionTechnologyWizard(models.TransientModel):
@@ -88,7 +89,10 @@ class ProductionTechnologyWizard(models.TransientModel):
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
- if workorder[0].state in ['pending']:
- if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
- workorder[0].state = 'waiting'
+ first_element = workorder[0] if workorder else None
+ if not first_element:
+ raise UserError('工艺确认后,工单未生成,请检查配置')
+ if first_element.state in ['pending']:
+ if first_element.production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
+ first_element.state = 'waiting'
return productions