summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-14 14:59:47 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-14 14:59:47 +0700
commit05fc26b12693250b29606e0eb7fc297f16716099 (patch)
treef7942b65f0802f0e3a95ce1d905d667185d7834c
parent89f27a69415d8ffbadbfbab0e23af9cada86d163 (diff)
<iman> add field on product
-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 '',