# Product showing as out of stock even if not active

**URL:** https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504
**Category:** uncategorized
**Created:** [February 19, 2022, 9:59pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504 "2022-02-19T21:59:27Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Douma](https://community.openboxes.com/user_avatar/community.openboxes.com/david_douma/32/326_2.png) [@David\_Douma](https://community.openboxes.com/u/David_Douma)
#### Post date: [February 19, 2022, 9:59pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/1 "2022-02-19T21:59:28Z")

</div>

Hi,

I have 2 products that keeps saying ‘out of stock’ on the dashboard.

 ![Firefox_Screenshot_2022-02-19T21-58-20.592Z](https://community.openboxes.com/uploads/default/original/1X/1d219d07cf612568f9cf4f219cf81f0a91c5cd1f.png)

I’ve tried deleting the product but that was not allowed. So I deactivated them, still showing up. I tried deleted the inventory levels, same thing… still showing up.

 ![Firefox_Screenshot_2022-02-19T21-58-02.914Z](https://community.openboxes.com/uploads/default/original/1X/4b94c1780c8fd233f02b87b89ce8831cfe437764.png)

Help! haha 🙂

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [February 21, 2022, 2:52am UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/2 "2022-02-21T02:52:31Z")

</div>

Can you show me the Stock History for each of those products?

---

<div class="post-metadata">

### Author: ![Jeferson\_Costa](https://community.openboxes.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@Jeferson\_Costa](https://community.openboxes.com/u/Jeferson_Costa)
#### Post date: [November 22, 2024, 2:09pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/3 "2024-11-22T14:09:36Z")

</div>

Any suggestions on how to actually deactivate a product? The product is already inactive but is still listed in reports.

---

<div class="post-metadata">

### Author: ![knagel](https://community.openboxes.com/letter_avatar_proxy/v4/letter/k/f475e1/32.png) [@knagel](https://community.openboxes.com/u/knagel)
#### Post date: [November 22, 2024, 2:32pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/4 "2024-11-22T14:32:47Z")

</div>

You can mark them as not supported on the inventory level screen. Edit product\>Inventory Levels tab\>Create stock level\>Choose not supported and create.

That should work, although it might depend on the version. Worth noting that 0.9.5, which is coming out in summer 2025, will contain an update to this indicator to filter the out of stock and make it more useful.

---

<div class="post-metadata">

### Author: ![knagel](https://community.openboxes.com/letter_avatar_proxy/v4/letter/k/f475e1/32.png) [@knagel](https://community.openboxes.com/u/knagel)
#### Post date: [November 22, 2024, 2:34pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/5 "2024-11-22T14:34:25Z")

</div>

Also please consider filling out our quick community survey so that we can better understand your implementation and your needs! [Microsoft Forms](https://forms.office.com/Pages/ResponsePage.aspx?id=n3hUUmBodUOFvDAlCfrVCIKfoFvOUZtDnq_EhlbrvitUREhSWkRNQzJRSDBLRzUzWUFPSlVBMDBPTC4u)

---

<div class="post-metadata">

### Author: ![Jeferson\_Costa](https://community.openboxes.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@Jeferson\_Costa](https://community.openboxes.com/u/Jeferson_Costa)
#### Post date: [November 22, 2024, 5:34pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/6 "2024-11-22T17:34:20Z")

</div>

It had no effect. In Reporting \> Inventory By Location Report the inactive product continues to appear.

---

<div class="post-metadata">

### Author: ![knagel](https://community.openboxes.com/letter_avatar_proxy/v4/letter/k/f475e1/32.png) [@knagel](https://community.openboxes.com/u/knagel)
#### Post date: [November 22, 2024, 6:29pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/7 "2024-11-22T18:29:55Z")

</div>

This is likely an issue with the behavior of that report. It probably wasn’t built to filter out those lines. If you are a software developer or have access to one, Justin might be able to advise you how to apply criteria to the report.

---

<div class="post-metadata">

### Author: ![Jeferson\_Costa](https://community.openboxes.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@Jeferson\_Costa](https://community.openboxes.com/u/Jeferson_Costa)
#### Post date: [November 25, 2024, 10:19am UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/8 "2024-11-25T10:19:18Z")

</div>

OK thanks. @jmiranda, can you give an idea of ​​how to filter so as not to list inactive products?

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [January 7, 2025, 9:14pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/9 "2025-01-07T21:14:10Z")

</div>

Sorry for the late response. I assume we’ll need to make a code change for this.

---

<div class="post-metadata">

### Author: ![David\_Douma](https://community.openboxes.com/user_avatar/community.openboxes.com/david_douma/32/326_2.png) [@David\_Douma](https://community.openboxes.com/u/David_Douma)
#### Post date: [January 16, 2025, 9:17am UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/10 "2025-01-16T09:17:08Z")

</div>

Is there a way, at this moment, to disable showing products in a warehouse that have 0 stock but don’t need no longer stock for this warehouse?

 ![image](https://community.openboxes.com/uploads/default/original/2X/9/95602e7bd2c1a38f7b617bf66288819e2d5b66d1.png)

As example, above product was in stock in that warehouse, but doesn’t need to be in stock in that warehouse anymore, but in others. But it keeps showing 0 / not in stock.

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [January 16, 2025, 8:51pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/11 "2025-01-16T20:51:40Z")

</div>

From within the application, I don’t think there’s a way to do it, but I agree that there should be. You should be able to delete products and have that cascade throughout the application (order items, shipment items, etc). However, we also have tables that have been derived using that data (product\_availability, product\_demand, reporting fact tables) so the feature required to delete a product is much more involved and complex than it might appear.

There’s actually one way to make a product “disappear” within the application. You can merge a product into another product if this is indeed a duplicate product. If it’s not, I would discourage the use of the product merge feature.

Within the database, you can delete the product assuming you delete all of the records within tables that reference that product\_id (including but not limited to inventory\_item, shipment\_item, transaction\_entry, order\_item, product\_dimension, product\_availability, etc). The problem is that it’s difficult to figure out the ordering of deletes to make this less frustrating. But you could do it.

You _could_ also disable foreign key checks and attempt to delete the product and all of its references, but you’ll probably run into some weird behavior at some point if you miss some of the referential data i.e. when you open a shipment that still has a foreign key to the deleted product. So I would avoid that until you identify and delete all of the reference data.

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [January 16, 2025, 9:19pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/12 "2025-01-16T21:19:50Z")

</div>

Here’s a query to return all database objects related to the

```auto
SELECT tables.table_schema as database_name, tables.table_name, tables.table_type 
FROM information_schema.columns  
JOIN information_schema.tables ON (information_schema.columns.table_schema = information_schema.tables.table_schema  
AND information_schema.columns.table_name = information_schema.tables.table_name)
WHERE column_name IN ('product_id') 
AND tables.table_schema = 'openboxes' 
# AND tables.table_type = 'BASE TABLE'
ORDER BY tables.table_name;

```

NOTE: I wanted to provide a query that returns all objects, but you can uncomment the table\_type clause to return only database objects that contain data i.e. table\_type = ‘BASE TABLE’.

And, here are the query results run against a development version of the database.

NOTE: This is a development database so you might see some tables here that you don’t see in your database. Therefore focus on your own query results.

```auto
+---------------+---------------------------------+------------+
| database_name | table_name | table_type |
+---------------+---------------------------------+------------+
| openboxes | consumption | BASE TABLE |
| openboxes | cycle_count_request | BASE TABLE |
| openboxes | cycle_count_session | VIEW |
| openboxes | edit_page_item | VIEW |
| openboxes | fill_rate | VIEW |
| openboxes | inventory_item | BASE TABLE |
| openboxes | inventory_level | BASE TABLE |
| openboxes | inventory_snapshot | BASE TABLE |
| openboxes | invoice_item | BASE TABLE |
| openboxes | on_order_order_item_summary | VIEW |
| openboxes | on_order_shipment_item_summary | VIEW |
| openboxes | on_order_summary | VIEW |
| openboxes | order_item | BASE TABLE |
| openboxes | order_item_details | VIEW |
| openboxes | order_item_summary | VIEW |
| openboxes | product_association | BASE TABLE |
| openboxes | product_attribute | BASE TABLE |
| openboxes | product_availability | BASE TABLE |
| openboxes | product_availability_computed | BASE TABLE |
| openboxes | product_catalog_item | BASE TABLE |
| openboxes | product_category | BASE TABLE |
| openboxes | product_demand | VIEW |
| openboxes | product_demand_details | BASE TABLE |
| openboxes | product_demand_details_tmp | BASE TABLE |
| openboxes | product_dimension | BASE TABLE |
| openboxes | product_document | BASE TABLE |
| openboxes | product_expiry_summary | VIEW |
| openboxes | product_group_product | BASE TABLE |
| openboxes | product_inventory_compare_view | VIEW |
| openboxes | product_inventory_expiry_view | VIEW |
| openboxes | product_inventory_extended_view | VIEW |
| openboxes | product_inventory_pivot_view | VIEW |
| openboxes | product_inventory_snapshot_view | VIEW |
| openboxes | product_package | BASE TABLE |
| openboxes | product_snapshot | VIEW |
| openboxes | product_stocklist | VIEW |
| openboxes | product_stockout | VIEW |
| openboxes | product_stockout_status | VIEW |
| openboxes | product_substitution_status | VIEW |
| openboxes | product_summary | VIEW |
| openboxes | product_supplier | BASE TABLE |
| openboxes | product_supplier_clean | VIEW |
| openboxes | product_tag | BASE TABLE |
| openboxes | receipt_item | BASE TABLE |
| openboxes | requirement | VIEW |
| openboxes | requisition_item | BASE TABLE |
| openboxes | shipment_item | BASE TABLE |
| openboxes | stocklist_item_list | VIEW |
| openboxes | stock_movement_item | VIEW |
| openboxes | substitution_item | VIEW |
| openboxes | synonym | BASE TABLE |
| openboxes | transaction_entry | BASE TABLE |
+---------------+---------------------------------+------------+
52 rows in set (0.020 sec)

```

There are some potentially complex associations between a lot of these tables. For example, inventory\_item references product\_id and lots of other tables reference inventory\_item\_id alone or sometimes both product\_id and inventory\_item\_id. So you might need to find all of the records that contain a reference to the product itself or one of its inventory items.

Once you have the list, report back here and I can provide further instructions. I would also strongly recommend creating a database backup before you start this exercise just in case.

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [January 16, 2025, 9:27pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/13 "2025-01-16T21:27:19Z")

</div>

By the way, here’s an older ticket that explains the reason for not allowing users to delete products and suggests an alternative. The alternative is much harder to implement than the hard delete so I might think about creating a ticket for hard delete that is accessible to the superuser role.

> <https://github.com/openboxes/openboxes/issues/214>
>
> Currently, you cannot delete a product that is referenced by other tables (inven…tory item, transactions, shipment items, etc). This was done to prevent data corruption as deleting a product is a very destructive operation that should only be done as a last resort. In addition, attempts to cascade delete all objects associated with a product fail due to what appears to be a Hibernate bug. 
> 
> Given that we don't want to destroy records in the database, the next obvious solution would be to mark the object as deleted and prevent it from showing up in queries. However, there's no baked-in solution to this problem in GORM/Hibernate, so we need to roll our own solution. Marking a product as deleted requires the product to be filtered out for all queries related to products within the system (including anything to do with inventory items). This is a pretty large under taking and will take some research to figure out.
> 
> !\[openboxes-cannot-delete-product\](https://user-images.githubusercontent.com/1162935/30171895-c642edd8-93b8-11e7-97d5-da9a31b9ad0a.png)

---

<div class="post-metadata">

### Author: ![David\_Douma](https://community.openboxes.com/user_avatar/community.openboxes.com/david_douma/32/326_2.png) [@David\_Douma](https://community.openboxes.com/u/David_Douma)
#### Post date: [January 16, 2025, 9:34pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/14 "2025-01-16T21:34:54Z")

</div>

> [@jmiranda](#):
>
> n f

Thnx for the follow-up. Problem is that I don’t want to delete a product in total but only not showing as 0 (zero) stock in some warehouses if they are depleted and no longer in use in that warehouse.

---

<div class="post-metadata">

### Author: ![jmiranda](https://community.openboxes.com/user_avatar/community.openboxes.com/jmiranda/32/199_2.png) [@jmiranda](https://community.openboxes.com/u/jmiranda)
#### Post date: [January 16, 2025, 9:46pm UTC](https://community.openboxes.com/t/product-showing-as-out-of-stock-even-if-not-active/504/15 "2025-01-16T21:46:19Z")

</div>

As far as I know, the products showing up in that report are included because there are transactions in that particular location for that product. I’ll check the code to verify that is true. If that’s the case they only way to remove those products from those reports is to remove the transactions against those products in that location.

At least that is how we intended to build that particular report, if I’m not mistaken. If I’m wrong about that then this would require a bug fix. In addition, if a product is inactive, theoretically, it should not show up anywhere in the system. However, the inactive filter probably hasn’t been applied across all features and reports. I think when we first implemented the inactive flag (for product), the most important features for excluding these products were the Product Search and Global Search.

There’s a feature within the system called Inventory Level status that allows you to mark a product Supported vs Not Supported for a given location. This worked with the legacy dashboard and some reports, but I don’t think is used across newer features. I think there’s a plan to resurrect / refactor the Inventory Level feature in the near future, but we’ll try to get to the bottom of this ahead of that.
