[FIX] sale_product_configurator: exclude product deleted

Before this commit, the product configurator did not handle a deleted
product variant if a product variant had instantly create attribute, but
was deleted from the database.

Now, the product configurator will consider a combination `archived` if
the product variant doesn't exist (based on its id) and its create_mode
is `always`.

opw-3487571

closes odoo/odoo#139986

X-original-commit: 7abeb13ae53962694ec7fb02de133fc3d7a82908
Signed-off-by: Valentin Chevalier <vcr@odoo.com>
This commit is contained in:
Valentin Chevalier
2023-10-27 13:02:27 +00:00
parent 245d6f00d8
commit 573c689a9b
@@ -234,6 +234,13 @@ export class ProductConfiguratorDialog extends Component {
if (this._isPossibleCombination(product)) {
const updatedValues = await this._updateCombination(product, product.quantity);
Object.assign(product, updatedValues);
// When a combination should exist but was deleted from the database, it should not be
// selectable and considered as an exclusion.
if (!product.id && product.attribute_lines.every(ptal => ptal.create_variant === "always")) {
const combination = this._getCombination(product);
product.archived_combinations = product.archived_combinations.concat([combination]);
this._checkExclusions(product);
}
}
}