diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 13:20:54 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 13:20:54 +0700 |
| commit | aec3028acc08c573b68a71b0144558f8fc091607 (patch) | |
| tree | 432c9c1e49264e366e697c087b6c9bdd8aa0b052 /indoteknik_custom/models | |
| parent | e24d74a1ca5af90086060374dddc309e102579ea (diff) | |
Add solr flag and add to queue on program line
Diffstat (limited to 'indoteknik_custom/models')
| -rw-r--r-- | indoteknik_custom/models/promotion/promotion_program_line.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/promotion_program_line.py | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index ce46d2e7..cb231889 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -30,7 +30,8 @@ class PromotionProgramLine(models.Model): discount_amount = fields.Float('Discount Amount') order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') - active = fields.Boolean(default=True) + active = fields.Boolean(string="Active", default=True) + solr_flag = fields.Integer(string="Solr Flag", default=1) def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 30ce16c9..b241b248 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -54,9 +54,7 @@ class PromotionProgramLine(models.Model): 'total_qty_i': sum([x.qty for x in rec.product_ids] + [x.qty for x in rec.free_product_ids]), 'active': rec.active }) - self.solr().add([document]) - self.solr().commit() @api.model @@ -67,3 +65,13 @@ class PromotionProgramLine(models.Model): def write(self, vals): self._create_solr_queue('_sync_to_solr') return super(PromotionProgramLine, self).write(vals) + + def solr_flag_to_queue(self, limit=500): + domain = [ + ('solr_flag', '=', 2), + ('active', 'in', [True, False]) + ] + records = self.search(domain, limit=limit) + for record in records: + record._create_solr_queue('_sync_to_solr') + record.solr_flag = 1 |
