[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 (`product.product`)
which uses an attribute (`product.attribute`) still used in other
variants

Steps to reproduce:
1. Install Sales and Stock
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' 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:
Make sure there is a product attribute value to disable before excluding
one in the ptavList

Problem:
A `product.product` of a `product.template` can be archived if it has
been used in past orders and a new `product.attribute` has been added to
the `product.template`. Thus, the old product attribute value will
appear in archivedCombinations but there is nothing to disable because
the `product.attribute` is still used.

opw-3413721

closes odoo/odoo#128465

X-original-commit: 8240a34a7f5b082aca4b495447abf87481a04913
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
MerlinGuillaume
2023-07-15 10:54:44 +02:00
parent 4db88dca07
commit da8997d87a
@@ -278,7 +278,9 @@ export class ProductConfiguratorDialog extends Component {
const disabledPtavId = excludedCombination.find(
(ptav) => !combination.includes(ptav)
);
ptavList.find(ptav => ptav.id === disabledPtavId).excluded = true;
if (disabledPtavId) {
ptavList.find(ptav => ptav.id === disabledPtavId).excluded = true;
}
}
}
}