From 080c8edc03a4c9f86b8719d72e6c0a55acd4c32b Mon Sep 17 00:00:00 2001 From: "Alexandre de Pape (alpa)" Date: Wed, 7 Sep 2022 14:44:22 +0000 Subject: [PATCH] [FIX] Traceback when adding a picture inside T&C This commits fixes the fact that we were having a traceback when puting an image inside a div that was in the div with id #product_detail and clicking on the remove button in the editor. In reality this butotn should not have been available because the image is not in the carousel. We now check that the image is in the o_wsale_product_images div (which is the carousel) to display the remove button. To remove an image outside of this carousel, simply click on the remove block button. task_id=2973363 closes odoo/odoo#99757 Signed-off-by: William Braeckman (wbr) --- addons/website_sale/controllers/main.py | 4 ++-- addons/website_sale/static/src/js/website_sale.editor.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 3d6e4e76e87..b2257321534 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -540,9 +540,9 @@ class WebsiteSale(http.Controller): image_res_id = int(image_res_id) if image_res_model == 'product.product': - request.env['product.product'].browse(image_res_id).image_1920 = False + request.env['product.product'].browse(image_res_id).write({'image_1920': False}) elif image_res_model == 'product.template': - request.env['product.template'].browse(image_res_id).image_1920 = False + request.env['product.template'].browse(image_res_id).write({'image_1920': False}) else: request.env['product.image'].browse(image_res_id).unlink() diff --git a/addons/website_sale/static/src/js/website_sale.editor.js b/addons/website_sale/static/src/js/website_sale.editor.js index 481e48543ef..3646358824e 100644 --- a/addons/website_sale/static/src/js/website_sale.editor.js +++ b/addons/website_sale/static/src/js/website_sale.editor.js @@ -959,7 +959,7 @@ options.registry.ReplaceMedia.include({ */ async willStart() { const parent = this.$target.parent(); - this.isProductPageImage = this.$target.closest('#product_detail').length > 0; + this.isProductPageImage = this.$target.closest('.o_wsale_product_images').length > 0; // Product Page images may be the product's image or a record of `product.image` this.recordModel = parent.data('oe-model'); this.recordId = parent.data('oe-id');