Skip to content

[REF] product: Set max iterations to look for product combinations#627

Open
moylop260 wants to merge 1 commit intoVauxoo:17.0from
vauxoo-dev:17.0-max-combination-moy
Open

[REF] product: Set max iterations to look for product combinations#627
moylop260 wants to merge 1 commit intoVauxoo:17.0from
vauxoo-dev:17.0-max-combination-moy

Conversation

@moylop260
Copy link

@moylop260 moylop260 commented Jun 3, 2025

Sometimes the products are stuck for a long time looking for combinations

This patch set max iterations for this infinite loop

It is reproduced with the following script

self.env.cr.execute("""
    SELECT ptal.product_tmpl_id,
        ARRAY_AGG(ptav.id) AS ptav2del
    FROM product_template_attribute_line AS ptal
    JOIN product_attribute AS pa
      ON ptal.attribute_id = pa.id
    JOIN product_template_attribute_value AS ptav
      ON ptal.id = ptav.attribute_line_id
    WHERE pa.create_variant = 'always'
      AND ptav.id IS NOT NULL
      AND ptal.active IS TRUE
    GROUP BY ptal.product_tmpl_id
""")
res = self.env.cr.fetchall()

for r in res:
    product_tmpl = self.env["product.template"].browse(r[0])
    product_templ_attr_vals = self.env["product.template.attribute.value"].browse(r[1])
    product_templ_attr_vals.unlink()
    print(product_tmpl)
    combination = product_tmpl._get_first_possible_combination()

@moylop260 moylop260 self-assigned this Jun 3, 2025
@moylop260 moylop260 added the PATCH label Jun 3, 2025
@moylop260 moylop260 force-pushed the 17.0-max-combination-moy branch 2 times, most recently from ef5a5c4 to f3265ce Compare June 5, 2025 14:13
@luisg123v
Copy link

Maybe this could be a fix to Odoo.

@moylop260 moylop260 changed the title [REF] product: Set max recursion to look for product combinations [REF] product: Set max iterations to look for product combinations Jun 5, 2025
@moylop260
Copy link
Author

moylop260 commented Jun 5, 2025

Maybe this could be a fix to Odoo.

I thought that, too

However, we need to justify it very well, and the current way to reproduce it is by deleting the product_template_attribute_value records and it is not reproduced functionally

The first impression looks like a migration issue for this database not reproducible from Odoo itself

But we keep checking...

BTW could you check the migration script used for this case, please?

@hugho-ad
Copy link
Collaborator

hugho-ad commented Jun 5, 2025

What about ese similar technique than the dynamic_variant_limit?

variant_limit = self.env['ir.config_parameter'].sudo().get_param('product.dynamic_variant_limit', 1000)

@moylop260 moylop260 force-pushed the 17.0-max-combination-moy branch 2 times, most recently from 76b4a5a to 2ff76ed Compare June 5, 2025 22:34
Sometimes the products are stuck for a long time looking for combinations

This patch set max iterations for this infinite loop
@moylop260 moylop260 force-pushed the 17.0-max-combination-moy branch from 2ff76ed to 6376582 Compare June 6, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants