From 799c216979fb4216422c2a584a763b286713b8d2 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 3 Oct 2024 10:04:18 +0700 Subject: add is in bu ke variant product solr --- indoteknik_custom/models/solr/product_template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/solr/product_template.py') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 1eb6f31b..70246ba3 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -74,7 +74,8 @@ 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), + ('quantity', '>', 0) ]) is_in_bu = bool(stock_quant) -- cgit v1.2.3 From 698cb0618c8bc90a02aeaa5ceb35818b26c71324 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 10 Oct 2024 09:20:09 +0700 Subject: update ready stock --- indoteknik_custom/models/solr/product_template.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indoteknik_custom/models/solr/product_template.py') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 70246ba3..029e0956 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -75,10 +75,9 @@ class ProductTemplate(models.Model): stock_quant = self.env['stock.quant'].search([ ('product_id', 'in', template.product_variant_ids.ids), ('location_id', 'in', target_locations), - ('quantity', '>', 0) ]) - 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 '' -- cgit v1.2.3 From 6b2cb9b1078b48aa97f8f06613eca9dc121a431e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 10 Oct 2024 09:47:39 +0700 Subject: ubah code untuk handle jika tidak ada category id --- indoteknik_custom/models/solr/product_template.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models/solr/product_template.py') 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'] -- cgit v1.2.3