Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2010 Представления

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

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор

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

Related Posts Ответы Просмотры Активность
1
мар. 24
2512