diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-14 16:12:14 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-14 16:12:14 +0700 |
| commit | d47eb069978ce67bce1a19b6c824a53ca3d68801 (patch) | |
| tree | 2427f680d68c8b136531d392eb36cf4262c7d35b /indoteknik_custom/models/solr | |
| parent | 2513b765773fca587dbd298e77732d2d005949c8 (diff) | |
| parent | d4df708e5195e1c0c3b8e0ad90b7518e5d4d48c2 (diff) | |
<iman> Merge branch 'production' of https://bitbucket.org/altafixco/indoteknik-addons into feature/tracking-order
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Diffstat (limited to 'indoteknik_custom/models/solr')
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 14 |
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 '', |
