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_product.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/solr/product_product.py') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 35e3a4b3..df20cc4b 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -47,6 +47,16 @@ class ProductProduct(models.Model): category_id = category.id category_name = category.name + # Check if the product's inventory location is in ID 57 or 83 + target_locations = [57, 83] + stock_quant = self.env['stock.quant'].search([ + ('product_id', 'in', variant.product_variant_ids.ids), + ('location_id', 'in', target_locations), + ('quantity', '>', 0) + ]) + + is_in_bu = bool(stock_quant) + document = solr_model.get_doc('variants', variant.id) document.update({ @@ -76,7 +86,8 @@ class ProductProduct(models.Model): 'publish_b': not variant.unpublished, 'sni_b': variant.sni, 'tkdn_b': variant.tkdn, - 'qty_sold_f': variant.qty_sold + 'qty_sold_f': variant.qty_sold, + "is_in_bu_b": is_in_bu, }) self.solr().add(docs=[document], softCommit=True) -- 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_product.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indoteknik_custom/models/solr/product_product.py') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index df20cc4b..7c10a910 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -52,10 +52,9 @@ class ProductProduct(models.Model): stock_quant = self.env['stock.quant'].search([ ('product_id', 'in', variant.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) document = solr_model.get_doc('variants', variant.id) -- cgit v1.2.3