From f588703c28fdfb83c8bfc78a6f106921d7901104 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 13 Apr 2022 14:42:37 +0000 Subject: [PATCH] [FIX] website_blog: make removed custom tags reusable Since [1] when the blog tags field option was refactored to use the m2m widget, the list of existing tags is not cleaned up anymore. This causes custom tags to remain in that list when they are removed. This commit adapts the existing condition to exclude custom tags that have been removed. Steps to reproduce: - edit blog - create custom tag 'test' - remove custom tag 'test' - create custom tag 'test' => was detecting the tag as already existing [1]: https://github.com/odoo/odoo/commit/4a603cd59c8a3f33d9515f28d99a0f68c381c5d2 task-2811746 X-original-commit: 7f58519b922264efb6b6180608fd5a461d30b9e8 Part-of: odoo/odoo#109479 --- addons/website_blog/static/src/js/options.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/website_blog/static/src/js/options.js b/addons/website_blog/static/src/js/options.js index 31a32ff86c3..ff813fd2471 100644 --- a/addons/website_blog/static/src/js/options.js +++ b/addons/website_blog/static/src/js/options.js @@ -111,7 +111,12 @@ options.registry.BlogPostTagSelection = options.Class.extend({ if (!widgetValue) { return; } - const existing = Object.values(this.allTagsByID).some(tag => tag.name.toLowerCase() === widgetValue.toLowerCase()); + const existing = Object.values(this.allTagsByID).some(tag => { + // A tag is already existing only if it was already defined (i.e. + // id is a number) or if it appears in the current list of tags. + return tag.name.toLowerCase() === widgetValue.toLowerCase() + && (typeof(tag.id) === 'number' || this.tagIDs.includes(tag.id)); + }); if (existing) { return this.displayNotification({ type: 'warning',