[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) <megu@odoo.com>
This commit is contained in:
MerlinGuillaume
2023-07-19 20:45:07 +02:00
parent b3d2004bfc
commit 641206cd82
@@ -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;
}
}
}