summaryrefslogtreecommitdiff
path: root/addons/website_sale/static
diff options
context:
space:
mode:
authorNasreddin (bon) <bon@odoo.com>2021-01-21 10:40:54 +0000
committerNasreddin (bon) <bon@odoo.com>2021-01-22 11:22:12 +0000
commite452d30f739db39a088248a3109c8c49cff9d49f (patch)
treee6c2b9c75d0d5ad077d7646681667ae8f56d7011 /addons/website_sale/static
parenta27907e27fb99a523c7b2d58544c36073640511c (diff)
[FIX] website: Warning message on website if dynamic snippet category deleted
Issue - Install "Ecommerce" app - Go to 'Shop' page and edit it - Add a "Dynamic Products" block - Click on it to edit it : - Select any template - Select `Desks` as product category - Save - Go to "Website -> Configuration -> eCommerce Categories" - Delete the "Desks" category - Go back to Shop page Error : "Record does not exist or has been deleted". Cause The search domain is looking for child categories of dataset.productCategoryId (who does not exist anymore in the above case). `child_of` do a browse() to fetch the records, and therefore generate an error if category not found. Solution Log warning message if unexptected domain and return empty records set instead. This commit also reverts commit 0de069b8ca9fb005ba5b076984f5677de25889ee that generated the issue. opw-2440917 closes odoo/odoo#64847 Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
Diffstat (limited to 'addons/website_sale/static')
-rw-r--r--addons/website_sale/static/src/snippets/s_dynamic_snippet_products/000.js24
1 files changed, 3 insertions, 21 deletions
diff --git a/addons/website_sale/static/src/snippets/s_dynamic_snippet_products/000.js b/addons/website_sale/static/src/snippets/s_dynamic_snippet_products/000.js
index 44225f83928..3763593f98f 100644
--- a/addons/website_sale/static/src/snippets/s_dynamic_snippet_products/000.js
+++ b/addons/website_sale/static/src/snippets/s_dynamic_snippet_products/000.js
@@ -14,18 +14,6 @@ const DynamicSnippetProducts = DynamicSnippetCarousel.extend({
//--------------------------------------------------------------------------
/**
- * Check product category exist.
- * @private
- * @returns {Promise}
- */
- _checkCategoryExist: async function (productCategoryId) {
- return this._rpc({
- model: 'product.public.category',
- method: 'search_count',
- args: [[['id', '=', productCategoryId]]],
- }).then(nb => nb > 0);
- },
- /**
* Method to be overridden in child components if additional configuration elements
* are required in order to fetch data.
* @override
@@ -40,15 +28,9 @@ const DynamicSnippetProducts = DynamicSnippetCarousel.extend({
* @override
* @private
*/
- _getSearchDomain: async function () {
- const searchDomain = await this._super.apply(this, arguments);
- const productCategoryId = parseInt(this.$el.get(0).dataset.productCategoryId);
- const categoryExist = await this._checkCategoryExist(productCategoryId);
- if (categoryExist) {
- searchDomain.push(['public_categ_ids', 'child_of', productCategoryId]);
- } else {
- searchDomain.push([0, '=', 1]);
- }
+ _getSearchDomain: function () {
+ const searchDomain = this._super.apply(this, arguments);
+ searchDomain.push(['public_categ_ids', 'child_of', parseInt(this.$el.get(0).dataset.productCategoryId)]);
return searchDomain;
},