[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) <wbr@odoo.com>
This commit is contained in:
Alexandre de Pape (alpa)
2022-09-09 02:41:51 +02:00
parent d41f6e7687
commit 080c8edc03
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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()
@@ -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');