İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1997 Görünümler

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Mar 24
2505