From 2a9768f6a09751af82ccabee3d565f622ea418f3 Mon Sep 17 00:00:00 2001
From: "Achraf (abz)" <abz@odoo.com>
Date: Wed, 5 Jan 2022 13:46:09 +0000
Subject: [PATCH] [FIX] wesbite_sale: Prevent traceback on website/shop without
 headers

When you disable the headers through the website editor and try to add
a product to the wishlist, a traceback occurs because there is an animation
that uses the dom element of the wishlist that doesn't exist.
We can avoid the animation in the case where the wish is not defined

reproducible in 14.0 with the wishlist (must be activated in settings)
and in 15.0 with the cart and the wishlist

opw-2722163

closes odoo/odoo#82247

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
---
 addons/website_sale/static/src/js/website_sale_utils.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/addons/website_sale/static/src/js/website_sale_utils.js b/addons/website_sale/static/src/js/website_sale_utils.js
index 52c3e448d526..57711d5e6ce5 100644
--- a/addons/website_sale/static/src/js/website_sale_utils.js
+++ b/addons/website_sale/static/src/js/website_sale_utils.js
@@ -2,6 +2,9 @@ odoo.define('website_sale.utils', function (require) {
 'use strict';
 
 function animateClone($cart, $elem, offsetTop, offsetLeft) {
+    if (!$cart.length) {
+        return Promise.resolve();
+    }
     $cart.find('.o_animate_blink').addClass('o_red_highlight o_shadow_animation').delay(500).queue(function () {
         $(this).removeClass("o_shadow_animation").dequeue();
     }).delay(2000).queue(function () {
-- 
GitLab