summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/solr
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-08-14 08:01:20 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-08-14 08:01:20 +0000
commitc5e742d609ec379b6d0228f8274b3d97bda9214d (patch)
tree0524cd84c752ca54a5e6b1cfeed949336d1d6083 /indoteknik_custom/models/solr
parent72befb1e3401a4c31dbf2698963ec52c5baba8cd (diff)
parent05fc26b12693250b29606e0eb7fc297f16716099 (diff)
Merged in feature/pickup-service (pull request #193)
Feature/pickup service
Diffstat (limited to 'indoteknik_custom/models/solr')
-rw-r--r--indoteknik_custom/models/solr/product_template.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 892e7334..6ad49af7 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -68,7 +68,17 @@ class ProductTemplate(models.Model):
# Mengumpulkan semua kategori
category_ids = [category.id for category in template.public_categ_ids]
category_names = [category.name for category in template.public_categ_ids]
-
+
+ # 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', template.product_variant_ids.ids),
+ ('location_id', 'in', target_locations)
+ ])
+
+ is_in_bu = bool(stock_quant)
+ on_hand_qty = sum(stock_quant.mapped('quantity')) if stock_quant else 0
+
document = solr_model.get_doc('product', template.id)
document.update({
"id": template.id,
@@ -99,6 +109,8 @@ class ProductTemplate(models.Model):
'sni_b': template.unpublished,
'tkdn_b': template.unpublished,
"qty_sold_f": template.qty_sold,
+ "is_in_bu_b": is_in_bu,
+ "on_hand_qty_i": on_hand_qty,
"voucher_pastihemat" : {
"min_purchase" : voucher.min_purchase_amount or 0,
"discount_type" : voucher.discount_type or '',