Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1992 Vistas

I'd like to set an automatic routine that hide product when it goes <= 0, and then show again when it goes > 0.

Both by saving a inventory in/out document, or updating manually product quantity.

Alternatively, may set a filter that excludes all zero quantity products from shop

Avatar
Descartar
Mejor respuesta

Hi,

The products in the /shop are only displayed when they have been published on the website. Find those products that you want to hide and in the tab Sales of the product form put it to non-published.So you can use the below code for that:-

products = env['product.product'].search([])
for prod in products:
if .qty_available == 0:
prod.write({'website_published': False})

Regards

Avatar
Descartar
Autor

Hi and thanks for your help.
What do you mean with "you can use the below code for that"?
Where to put it?

And, I can't see a trigger or field regarding publishing inside tab sales of product form. Only on e-commerce page preview/editing

Publicaciones relacionadas Respuestas Vistas Actividad
1
mar 24
2498