Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
2005 Visualizações

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
Cancelar
Melhor resposta

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

Publicações relacionadas Respostas Visualizações Atividade
1
mar. 24
2510