diff options
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 13 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 3 |
2 files changed, 14 insertions, 2 deletions
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) 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) |
