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