diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-28 14:07:47 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-28 14:07:47 +0700 |
| commit | 00b6739e4f4228c1cc66de0ef63312bc633ae21f (patch) | |
| tree | 85f8fc83d4030878893599abb2a949e5d478e3e7 /indoteknik_custom/models/solr/promotion_program_line.py | |
| parent | 0738a192409687790c16c757f85fe440cb1f377d (diff) | |
| parent | 46a7cc5601ceab2a7a6cdf4d74e0fa26ce13ab8a (diff) | |
Merge branch 'production' into purchasing-job
Diffstat (limited to 'indoteknik_custom/models/solr/promotion_program_line.py')
| -rw-r--r-- | indoteknik_custom/models/solr/promotion_program_line.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 6e182324..9cd226fb 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -39,9 +39,8 @@ class PromotionProgramLine(models.Model): document.update({ 'id': rec.id, - 'program_id_i': rec.program_id.id, + 'program_id_i': rec.program_id.id or 0, 'name_s': rec.name, - 'image_s': self.env['ir.attachment'].api_image(self._name, 'image', rec.id) if rec.image else '', 'type_value_s': promotion_type['value'], 'type_label_s': promotion_type['label'], 'package_limit_i': rec.package_limit, @@ -53,10 +52,9 @@ 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]), + 'active_b': 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 |
