From b2be7e719365f23088964c72b2f027aead2ac5f9 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 2 Oct 2020 15:04:57 +0000 Subject: [PATCH] [FIX] sale: default on product change in configurator When a product is set on a line and we change product with the product configurator wizard, we will use the attributes values of the previous product. But then since the attributes are the ones of wrong product, not attribute is selected and if eg. we have radio button with one option and custom value, it will never be selectable (because the radio button is hidden and unselected). In this commit, we do not use the current variant values when we change product in the product configurator wizard. note: this commit also increases the limit of (custom values) inside the product configurator wizard, for an arbitrary 10000 limit. Without this change, each opening of the wizard would only keep 40 customs values and discard the other ones. opw-2333091 closes #59016 closes odoo/odoo#59803 X-original-commit: e9c54f6b3d5c36b658308e1900ab68dcc9de0357 Signed-off-by: Nicolas Lempereur (nle) --- .../static/src/js/product_configurator_controller.js | 6 ++++-- .../wizard/sale_product_configurator_views.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/sale_product_configurator/static/src/js/product_configurator_controller.js b/addons/sale_product_configurator/static/src/js/product_configurator_controller.js index 0fd8b042d6e..008e6e65fea 100644 --- a/addons/sale_product_configurator/static/src/js/product_configurator_controller.js +++ b/addons/sale_product_configurator/static/src/js/product_configurator_controller.js @@ -112,6 +112,8 @@ var ProductConfiguratorFormController = FormController.extend({ */ _configureProduct: function (productTemplateId) { var self = this; + var initialProduct = this.initialState.data.product_template_id; + var changed = initialProduct && initialProduct.data.id !== productTemplateId; var data = this.renderer.state.data; return this._rpc({ route: '/sale_product_configurator/configure', @@ -119,10 +121,10 @@ var ProductConfiguratorFormController = FormController.extend({ product_template_id: productTemplateId, pricelist_id: this.renderer.pricelistId, add_qty: data.quantity, - product_template_attribute_value_ids: this._getAttributeValueIds( + product_template_attribute_value_ids: changed ? [] : this._getAttributeValueIds( data.product_template_attribute_value_ids ), - product_no_variant_attribute_value_ids: this._getAttributeValueIds( + product_no_variant_attribute_value_ids: changed ? [] : this._getAttributeValueIds( data.product_no_variant_attribute_value_ids ) } diff --git a/addons/sale_product_configurator/wizard/sale_product_configurator_views.xml b/addons/sale_product_configurator/wizard/sale_product_configurator_views.xml index 8286db9c0bb..ef094e76899 100644 --- a/addons/sale_product_configurator/wizard/sale_product_configurator_views.xml +++ b/addons/sale_product_configurator/wizard/sale_product_configurator_views.xml @@ -9,7 +9,7 @@ - +