Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1186 Vistas

Hello everyone


How would be the best way to prevent products that have inventory existance to be archived?

Let's say there's a product with 100units in existance, and by mistake, one of the admin users archives it. The units would remain in existence, but nobody would be able to find it. 

Which would be the best way to prevent this?

Avatar
Descartar
Mejor respuesta

Hi everyone 👋

Great question — this is a common concern, especially for inventory-driven businesses where products should not be archived if stock still exists.

✅ Goal

Prevent users from archiving a product if it has stock on hand, to avoid making it “disappear” from the system while still holding value in inventory.

🔐 Option 1: Use a Server Action or Automated Rule (no coding)

You can create a server action or automated action that prevents archiving if the qty_available is greater than 0:

  1. Activate Developer Mode
  2. Go to Settings > Technical > Automated Actions
  3. Create a new action on model Product Template
  4. Trigger on write
  5. Add a condition like:

    python

    CopyEdit

    if record.active == False and record.qty_available > 0: raise UserError("This product has stock and cannot be archived.")

This blocks users from archiving products that still have quantities in stock.

🛠 Option 2: Custom Module (cleaner, more robust)

If you're comfortable with a bit of development, a custom module could override the unlink or write method for product.template and raise an error when trying to deactivate a product that has stock.

It’s more robust, especially if you need to add additional rules (e.g. checking stock across multiple warehouses, or also blocking archiving from list views).

🧠 Bonus Tip

If you use Odoo Studio, you can hide or disable the “archive” button conditionally — but this is more of a visual safeguard, and can be bypassed. It's best combined with one of the above methods for real protection.

Hope that helps! Let me know if you’d like help with the code snippet or Studio setup. 😊

Avatar
Descartar
Autor Mejor respuesta

There is no standarday way to prevent this, unfortunately. The best and most simple way would be just to manage the users' permissions and allow only certain users to archive products.

Think about this: how many clicks are needed to archive a product?
An example would be: manufacturing app>search product>product>actions>archive>confirm the product to be archived, at least 6 clicks are needed.

I got the same situation with a client, but for what I saw, there was no standarday way. At the end we managed to add permissions only to a certain group of people to archive products, they should be responsible enough to look up the inventory before archiving something.

I hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
dic 24
919
1
jul 25
433
1
may 25
576
3
abr 25
999
2
mar 15
13392