From 4e3710879f6e0758035d5161f2f5bcb911a08d3e Mon Sep 17 00:00:00 2001 From: niyasraphy Date: Thu, 5 Oct 2023 20:47:02 +0300 Subject: [PATCH] [IMP] product: add system parameter to control maximum product limit before this commit, if the entered attribute combination in template is creating more than 1000 product, the operation is prevented by raising UserError. as of now, there is no option to increase or decrease the limit if user need to do so. system parameter: product.dynamic_variant_limit after this commit, if user needs to increase or decrease the limit, it can be done by adding a system parameter and set the needed value closes odoo/odoo#137783 Signed-off-by: Victor Feyens (vfe) --- addons/product/models/product_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 04a70d5fea6..1cb759ac91d 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -728,9 +728,10 @@ class ProductTemplate(models.Model): current_variants_to_activate += existing_variants[combination] else: current_variants_to_create.append(tmpl_id._prepare_variant_values(combination)) - if len(current_variants_to_create) > 1000: + variant_limit = self.env['ir.config_parameter'].sudo().get_param('product.dynamic_variant_limit', 1000) + if len(current_variants_to_create) > int(variant_limit): raise UserError(_( - 'The number of variants to generate is too high. ' + 'The number of variants to generate is above allowed limit. ' 'You should either not generate variants for each combination or generate them on demand from the sales order. ' 'To do so, open the form view of attributes and change the mode of *Create Variants*.')) variants_to_create += current_variants_to_create