From 641206cd824aea8f3d3d03de23bd3de0af818564 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Tue, 18 Jul 2023 11:30:58 +0000 Subject: [PATCH] [FIX] sale_product_configurator: use product with archived variant In a sale order, an error is raised when selecting a product (`product.template`) that has an archived variant if the product has a single active attribute Steps to reproduce: 1. Install Sales 2. Create a new product 'TEST' 3. Add the attribute 'Legs' with values 'Steel' and 'Aluminium' 4. Create a new sale order for any customer with product 'TEST' and variant 'Steel' and confirm it 5. Open the form of product 'TEST', remove the attribute 'Legs' and add the attribute 'Color' with values 'White' and 'Black' 6. Create a new sale order and try to add the product 'TEST', an error is raised Solution: Exclude `product.template.attribute.value` from the ptavList only if it is present in the ptavList Problem: If a product has an archived variant that uses the same attributes than an existing active variants except one, we will try to exclude the different attribute but because it has been archived, it is not present and cannot be excluded. opw-3420616 closes odoo/odoo#129012 X-original-commit: 907aba0f54f65788c78c1370a573fbe9b69be8c5 Signed-off-by: Guillaume Merlin (megu) --- .../product_configurator_dialog.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js b/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js index d728df02637..2e1d267e847 100644 --- a/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js +++ b/addons/sale_product_configurator/static/src/js/product_configurator_dialog/product_configurator_dialog.js @@ -278,8 +278,9 @@ export class ProductConfiguratorDialog extends Component { const disabledPtavId = excludedCombination.find( (ptav) => !combination.includes(ptav) ); - if (disabledPtavId) { - ptavList.find(ptav => ptav.id === disabledPtavId).excluded = true; + const excludedPtav = ptavList.find(ptav => ptav.id === disabledPtavId) + if (excludedPtav) { + excludedPtav.excluded = true; } } }