diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-10-03 03:05:15 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-10-03 03:05:15 +0000 |
| commit | 5d3accd9e7f1321ef93cf4a8ce8b8f472143a72f (patch) | |
| tree | a9ab41840897167ea0d45194ca59e4326af1eec9 | |
| parent | 16ddcb43b85c1deeda29bf6bb5db4ef73b8d20d2 (diff) | |
| parent | 799c216979fb4216422c2a584a763b286713b8d2 (diff) | |
Merged in iman/add-isInBu (pull request #236)
<iman> add is in bu ke variant product solr
| -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) |
