Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: eCommerce

Entity: product.template

Compute Method: _compute_is_published

View 20.0
Inputs Method Outputs
  • id
  • is_storable
  • allow_out_of_stock_order
  • product_variant_ids
+ """Auto-unpublish a product when all variants are out of stock, republish when restocked."""
+ if not self.env["res.groups"]._is_feature_enabled(
+             "website_sale.group_unpublish_out_of_stock"
+         ):
+             return
+ for template in self:
+             if not template.id or not template.is_storable or template.allow_out_of_stock_order:
+                 continue
+             out_of_stock = all(variant.free_qty <= 0 for variant in template.product_variant_ids)
+             template.is_published = not out_of_stock
  • is_published

Back to entity