diff --git a/sf_warehouse/migrations/1.2/post-migrate.py b/sf_warehouse/migrations/1.2/post-migrate.py
index f4a0d9a4..8efec3c8 100644
--- a/sf_warehouse/migrations/1.2/post-migrate.py
+++ b/sf_warehouse/migrations/1.2/post-migrate.py
@@ -4,8 +4,14 @@ def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
sf_shelf_model = env["sf.shelf"]
sf_shelf_location_model = env["sf.shelf.location"]
+
+ preproduction_shelf_ids = sf_shelf_location_model.get_preproduction_shelf_ids()
+
shelves = sf_shelf_model.search([])
for shelf in shelves:
+ if shelf.id not in preproduction_shelf_ids:
+ continue
+
shelf_barcode = shelf.barcode or ""
if not shelf_barcode:
continue
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 8b9a86e4..8b19bd81 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -470,7 +470,6 @@ class ShelfLocation(models.Model):
record.display_rfid = record.product_sn_id.rfid if record.product_sn_id else ''
except Exception as e:
record.display_rfid = ''
- _logger.error(f"计算 display_rfid 时出错: {e}")
@api.depends('product_id')
def _compute_tool(self):
@@ -600,6 +599,24 @@ class ShelfLocation(models.Model):
_layer_capacity = f"{_layer_capacity:02d}"
record.kanban_show_layer_info=f"{_layer}-{_layer_capacity}"
record.kanban_show_center_control_code=f"{_cc_code}"
+ @api.model
+ def get_preproduction_shelf_ids(self):
+ """
+ 获取预生产区域的货架ID列表
+ Returns:
+ list: 货架ID列表
+ """
+ query = """
+ SELECT DISTINCT b.shelf_id
+ FROM stock_location a
+ LEFT JOIN sf_shelf_location b ON a.id = b.location_id
+ WHERE a.barcode LIKE 'WH-PREPRODUCTION'
+ """
+ self.env.cr.execute(query)
+ result = self.env.cr.fetchall()
+ # 将结果转换为ID列表
+ shelf_ids = [record[0] for record in result if record[0]]
+ return shelf_ids
class SfShelfLocationLot(models.Model):
_name = 'sf.shelf.location.lot'
@@ -616,6 +633,7 @@ class SfShelfLocationLot(models.Model):
for item in self:
if item.qty_num > item.qty:
raise ValidationError('变更数量不能比库存数量大!!!')
+
class SfStockMoveLine(models.Model):
diff --git a/sf_warehouse/static/src/js/custom_kanban_controller.js b/sf_warehouse/static/src/js/custom_kanban_controller.js
index ab3a57d6..2d591505 100644
--- a/sf_warehouse/static/src/js/custom_kanban_controller.js
+++ b/sf_warehouse/static/src/js/custom_kanban_controller.js
@@ -28,8 +28,18 @@ class CustomKanbanController extends KanbanController {
isBaseStyle: true
});
let self = this;
- // 获取货架分层数据
+
onWillStart(async () => {
+ try {
+ this.preproductionShelfIds = await this.orm.call(
+ 'sf.shelf.location',
+ 'get_preproduction_shelf_ids',
+ []
+ );
+ } catch (error) {
+ this.preproductionShelfIds = [];
+ }
+
this.searchModel.on('update', self, self._onUpdate);
await this.loadShelfLayersData();
});
@@ -50,7 +60,11 @@ class CustomKanbanController extends KanbanController {
let domain = this.searchModel.domain;
if (domain.length > 0) {
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
- this.onShelfChange(shelfDomain[2]);
+ if (shelfDomain && shelfDomain[2] && this.preproductionShelfIds && this.preproductionShelfIds.includes(shelfDomain[2])) {
+ this.onShelfChange(shelfDomain[2]);
+ } else {
+ this.setKanbanStyle('sf_kanban_location_style');
+ }
} else {
this.setKanbanStyle('sf_kanban_location_style');
}
@@ -63,8 +77,7 @@ class CustomKanbanController extends KanbanController {
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
if (shelfDomain) {
let shelfId = shelfDomain[2];
- // 如果货架ID存在,则设置相应的样式
- if (shelfId) {
+ if (shelfId && this.preproductionShelfIds.includes(shelfId)) {
this.onShelfChange(shelfId);
return;
}
@@ -75,7 +88,6 @@ class CustomKanbanController extends KanbanController {
this.setKanbanStyle('sf_kanban_location_style');
} catch (error) {
}
-
}
// 加载所有货架的层数数据
@@ -107,10 +119,18 @@ class CustomKanbanController extends KanbanController {
// 添加新类
if (isHave) kanbanViewEl.classList.add(style);
}
- const ghostCards = document.querySelectorAll('.o_kanban_ghost');
- ghostCards.forEach(card => {
- card.remove();
- });
+
+ // 获取当前的搜索域
+ let domain = this.searchModel.domain;
+ let shelfDomain = domain.find(item => item[0] === 'shelf_id');
+
+ // 只有当shelf_id在preproductionShelfIds中时才删除幽灵看板
+ if (shelfDomain && this.preproductionShelfIds && this.preproductionShelfIds.includes(shelfDomain[2])) {
+ const ghostCards = document.querySelectorAll('.o_kanban_ghost');
+ ghostCards.forEach(card => {
+ card.remove();
+ });
+ }
}
updatePagerLimit(limit) {
diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml
index 8b7bf9b6..82548935 100644
--- a/sf_warehouse/views/shelf_location.xml
+++ b/sf_warehouse/views/shelf_location.xml
@@ -229,7 +229,7 @@
-
+