From 6ec298fabe55b3663c2e800cdf522673d0dc642c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leloup=20Lo=C3=AFc=20=28lole=29?= Date: Tue, 25 Jul 2023 13:00:23 +0000 Subject: [PATCH] [FIX] sale_product_configurator : fix variants dynamic creation Before this commit, when selecting a dynamic attribute on the configurator, an RPC call is made to the server, and the id of the variant was returned if it existed. If it didn't exist, the server didn't return the id, and the previous id, if any, was kept in the client, causing the dynamic creation to fail believing that the product was already created. Now, the server will return `False` as `id` if the variant is not yet created. This value will override any value previously saved as `id` in the client, allowing the creation of new variants when needed. opw-3423821 closes odoo/odoo#130720 X-original-commit: 4540f971db2d65bc3453e9579c39109775cd5794 Signed-off-by: Victor Feyens (vfe) --- addons/sale_product_configurator/controllers/main.py | 2 +- .../sale_product_configurator/static/src/js/product/product.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale_product_configurator/controllers/main.py b/addons/sale_product_configurator/controllers/main.py index 4408d071b25..88d290a0ff3 100644 --- a/addons/sale_product_configurator/controllers/main.py +++ b/addons/sale_product_configurator/controllers/main.py @@ -312,7 +312,7 @@ class ProductConfiguratorController(Controller): # and no_variant attributes into account. Also, drop the id which was auto-included by the # search but isn't relevant since it is supposed to be the id of a `product.product` record. if not product_or_template.is_product_variant: - basic_information.pop('id') + basic_information['id'] = False combination_name = combination._get_combination_name() if combination_name: basic_information.update( diff --git a/addons/sale_product_configurator/static/src/js/product/product.js b/addons/sale_product_configurator/static/src/js/product/product.js index 9e449ba446e..467f2c41744 100644 --- a/addons/sale_product_configurator/static/src/js/product/product.js +++ b/addons/sale_product_configurator/static/src/js/product/product.js @@ -10,7 +10,7 @@ export class Product extends Component { static components = { PTAL }; static template = "sale_product_configurator.product"; static props = { - id: { type: Number, optional: true }, + id: { type: [Number, {value: false}], optional: true }, product_tmpl_id: Number, display_name: String, description_sale: [Boolean, String], // backend sends 'false' when there is no description