diff options
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 12 |
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'] |
