add product_configurator_website_fix

This commit is contained in:
Luis 2026-09-01 11:40:08 +02:00
parent 29ef56b800
commit 83146e83ff
4 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import product_template

View file

@ -0,0 +1,35 @@
from odoo import models
class ProductTemplate(models.Model):
_inherit = "product.template"
def _get_possible_combinations(self, parent_combination=None, necessary_values=None):
"""Configurable templates keep no variants on purpose (see
``product_configurator._create_variant_ids``). For a non-dynamic
template core treats a combination without an existing variant as
impossible, so the generator walks the *whole* cartesian product
without ever yielding. Short-circuit it.
"""
self.ensure_one()
if self.config_ok:
return iter(())
return super()._get_possible_combinations(parent_combination, necessary_values)
def _get_first_possible_combination(
self, parent_combination=None, necessary_values=None
):
self.ensure_one()
if self.config_ok:
return self.env["product.template.attribute.value"]
return super()._get_first_possible_combination(
parent_combination, necessary_values
)
def _is_add_to_cart_possible(self, parent_combination=None):
"""A configurable product is always addable: the variant is created
when the configuration session is validated."""
self.ensure_one()
if self.config_ok:
return self.active and self._can_be_added_to_cart()
return super()._is_add_to_cart_possible(parent_combination)