summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-10 09:47:39 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-10 09:47:39 +0700
commit6b2cb9b1078b48aa97f8f06613eca9dc121a431e (patch)
treeaa424e0458d9e16a5fc96037592d4d80ae316503
parent698cb0618c8bc90a02aeaa5ceb35818b26c71324 (diff)
<iman> ubah code untuk handle jika tidak ada category id
-rw-r--r--indoteknik_custom/models/solr/product_template.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 029e0956..1d54cc9b 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -158,10 +158,14 @@ class ProductTemplate(models.Model):
traverse_category(category.parent_id.id)
# Start traversal from the initial category
- traverse_category(category_id)
-
- # Reverse the list to get the hierarchy from top level to the current level
- return list(reversed(category_ids))
+ if category_id: # Check if category_id is not an empty value
+ traverse_category(category_id)
+
+ # Reverse the list to get the hierarchy from top level to the current level
+ return list(reversed(category_ids))
+ else:
+ # If category_id is empty, return an empty list
+ return []
def _sync_price_to_solr(self):
solr_model = self.env['apache.solr']