summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-10-10 02:48:13 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-10-10 02:48:13 +0000
commit8d63c8fa2278182c02901a550103b5f670fe86c6 (patch)
tree889f89cc9a35608cf53ebd38d5926ec7faa34f37
parent7153f047a6c9e98a1a016a6e08379f495071c9a1 (diff)
parent6b2cb9b1078b48aa97f8f06613eca9dc121a431e (diff)
Merged in iman/update-readyStock (pull request #239)
<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']