summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-07-05 15:29:37 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-07-05 15:29:37 +0700
commit381523a34e7fdd780989378d9189ea22edb95e33 (patch)
tree09651e627d2f4e0f4bdc3c12490991319e6c7586
parent77c4f329788de87938c971de525b9717844978b8 (diff)
<iman> add total qty sold product for sorting promotion program
-rw-r--r--indoteknik_custom/models/solr/promotion_program_line.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py
index 8f62ecc0..1f1bf67b 100644
--- a/indoteknik_custom/models/solr/promotion_program_line.py
+++ b/indoteknik_custom/models/solr/promotion_program_line.py
@@ -2,6 +2,9 @@ from odoo import models, api
from typing import Type
import pysolr
import json
+import logging
+
+_logger = logging.getLogger(__name__)
class PromotionProgramLine(models.Model):
_inherit = 'promotion.program.line'
@@ -26,7 +29,8 @@ class PromotionProgramLine(models.Model):
products = [{
'product_id': x.product_id.id,
- 'qty': x.qty
+ 'qty': x.qty,
+ 'qty_sold': x.product_id.qty_sold
} for x in rec.product_ids]
free_products = [{
@@ -52,8 +56,11 @@ class PromotionProgramLine(models.Model):
'free_product_ids': [x.product_id.id for x in rec.free_product_ids],
'free_products_s': json.dumps(free_products),
'total_qty_i': sum([x.qty for x in rec.product_ids] + [x.qty for x in rec.free_product_ids]),
+ 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids],
'active_b': rec.active
})
+ _logger.info("Syncing document to Solr: %s", json.dumps(document, indent=2))
+
self.solr().add([document])
self.solr().commit()