[NEW] When shop is installed, disable all products

This commit is contained in:
Thomas Pot
2025-03-20 09:17:29 +01:00
parent 044b6f4a5a
commit 09864d8513

View File

@@ -23,3 +23,19 @@ def post_init_hook(env):
'domain': False,
'homepage_url': new_page.url
})
module_ecommerce = env['ir.module.module'].search([('name','=','website_sale')])
if module_ecommerce and module_ecommerce.state == 'installed':
# disable payment options:
for payment_method in env['payment.method'].search([]):
payment_method.write({
'active': False
})
_logger.error(f"________Disable payment method {payment_method.id}")
# Disable products
for product in env['product.template'].search([]):
product.write({
'website_published': False
})
_logger.error(f"________Disable product {product.id}")