Zum Inhalt springen
Menü
Diese Frage wurde gekennzeichnet
1 Antworten
2000 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen
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

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
März 24
2506