From 6ff0d84f96fc104033732c00a553eee16e432169 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 12 Jul 2024 16:41:03 +0700 Subject: add sync to solr promotion program --- indoteknik_custom/models/solr/promotion_program.py | 14 ++++++++++++++ .../views/promotion/promotion_program.xml | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/indoteknik_custom/models/solr/promotion_program.py b/indoteknik_custom/models/solr/promotion_program.py index 0d417b3e..583d7df3 100644 --- a/indoteknik_custom/models/solr/promotion_program.py +++ b/indoteknik_custom/models/solr/promotion_program.py @@ -66,3 +66,17 @@ class PromotionProgram(models.Model): for line in rec.program_line: line._create_solr_queue('_sync_to_solr') + 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 + + def action_sync_to_solr(self): + rec_ids = self.env.context.get('active_ids', []) + recs = self.search([('id', 'in', rec_ids)]) + recs._create_solr_queue('_sync_to_solr') \ No newline at end of file diff --git a/indoteknik_custom/views/promotion/promotion_program.xml b/indoteknik_custom/views/promotion/promotion_program.xml index 724f80c7..c9672b5a 100644 --- a/indoteknik_custom/views/promotion/promotion_program.xml +++ b/indoteknik_custom/views/promotion/promotion_program.xml @@ -71,4 +71,25 @@ sequence="1" action="promotion_program_action" /> + + Sync to Solr + + + code + model.action_sync_to_solr() + + + + Program Promotion: Solr Flag to Queue + 1 + hours + -1 + + + model.solr_flag_to_queue() + code + 55 + True + + \ No newline at end of file -- cgit v1.2.3 From 3681206164462bcd6fe84808b7639c5994a9510f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 13 Jul 2024 09:11:22 +0700 Subject: add image_s to solr promotion program --- indoteknik_custom/models/solr/promotion_program.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/solr/promotion_program.py b/indoteknik_custom/models/solr/promotion_program.py index 583d7df3..db029adc 100644 --- a/indoteknik_custom/models/solr/promotion_program.py +++ b/indoteknik_custom/models/solr/promotion_program.py @@ -30,6 +30,7 @@ class PromotionProgram(models.Model): 'id': rec.id, 'name_s': rec.name, 'banner_s': ir_attachment.api_image(self._name, 'banner', rec.id) if rec.banner else '', + 'image_s': ir_attachment.api_image(self._name, 'image', rec.id) if rec.banner else '', 'keywords': [x.name for x in rec.keyword_ids], 'line_ids': [x.id for x in rec.program_line], 'start_time_s': self._time_format(rec.start_time), -- cgit v1.2.3