diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
| commit | 9fa80c62cdffec5b91aaf2a2899d70d0f507c2e4 (patch) | |
| tree | 93ae8d82f774345f650bc8d072dea759c6e33363 /indoteknik_custom/models/solr/product_template.py | |
| parent | a21c5fe37529b2d2259d3b86d8e98730b2bc8513 (diff) | |
| parent | a7be93f4825967807f12e6bfbebcf090af8500fa (diff) | |
Merge branch 'production' into iman/switch-account
# Conflicts:
# indoteknik_api/controllers/api_v1/user.py
# indoteknik_custom/models/user_company_request.py
Diffstat (limited to 'indoteknik_custom/models/solr/product_template.py')
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 1eb6f31b..1d54cc9b 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -74,10 +74,10 @@ class ProductTemplate(models.Model): target_locations = [57, 83] stock_quant = self.env['stock.quant'].search([ ('product_id', 'in', template.product_variant_ids.ids), - ('location_id', 'in', target_locations) + ('location_id', 'in', target_locations), ]) - is_in_bu = bool(stock_quant) + is_in_bu = any(quant.available_quantity > 0 for quant in stock_quant) cleaned_desc = BeautifulSoup(template.website_description or '', "html.parser").get_text() website_description = template.website_description if cleaned_desc else '' @@ -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'] |
