From 37f6aa6b678d46ad3578505b0e78056f92ee19f8 Mon Sep 17 00:00:00 2001
From: Christophe Matthieu <chm@odoo.com>
Date: Thu, 4 May 2017 12:21:27 +0200
Subject: [PATCH] [FIX] web: should remove all unused tags when using
 datepicker

before this fix, a tag is added in the body but never removed
---
 addons/web/static/src/js/views/calendar/calendar_renderer.js | 1 +
 addons/web/static/tests/views/calendar_tests.js              | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js
index b73aa789e7b9..23d63aa90448 100644
--- a/addons/web/static/src/js/views/calendar/calendar_renderer.js
+++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js
@@ -190,6 +190,7 @@ return AbstractRenderer.extend({
         }
         if (this.$small_calendar) {
             this.$small_calendar.datepicker('destroy');
+            $('#ui-datepicker-div:empty').remove();
         }
         this._super.apply(this, arguments);
     },
diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js
index 68c37d4013a2..7010771e992f 100644
--- a/addons/web/static/tests/views/calendar_tests.js
+++ b/addons/web/static/tests/views/calendar_tests.js
@@ -683,7 +683,7 @@ QUnit.module('Views', {
     });
 
     QUnit.test('open form view', function (assert) {
-        assert.expect(2);
+        assert.expect(3);
 
         var calendar = createView({
             View: CalendarView,
@@ -748,6 +748,8 @@ QUnit.module('Views', {
         $('.modal button.btn:contains(Edit)').trigger('click');
 
         calendar.destroy();
+
+        assert.strictEqual($('#ui-datepicker-div:empty').length, 0, "should have a clean body");
     });
 });
 
-- 
GitLab