summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-07-12 16:41:03 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-07-12 16:41:03 +0700
commit6ff0d84f96fc104033732c00a553eee16e432169 (patch)
tree55336da6d07f499fa6442196c232ecdb523233a4
parent17fd1072ccd6f2f74f73dd2e52ce7f0120adb3ce (diff)
<iman> add sync to solr promotion program
-rw-r--r--indoteknik_custom/models/solr/promotion_program.py14
-rw-r--r--indoteknik_custom/views/promotion/promotion_program.xml21
2 files changed, 35 insertions, 0 deletions
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"
/>
+ <record id="ir_actions_server_promotion_program_sync_to_solr" model="ir.actions.server">
+ <field name="name">Sync to Solr</field>
+ <field name="model_id" ref="indoteknik_custom.model_promotion_program"/>
+ <field name="binding_model_id" ref="indoteknik_custom.model_promotion_program"/>
+ <field name="state">code</field>
+ <field name="code">model.action_sync_to_solr()</field>
+ </record>
+ <data noupdate="1">
+ <record id="cron_program_solr_flag_solr" model="ir.cron">
+ <field name="name">Program Promotion: Solr Flag to Queue</field>
+ <field name="interval_number">1</field>
+ <field name="interval_type">hours</field>
+ <field name="numbercall">-1</field>
+ <field name="doall" eval="False"/>
+ <field name="model_id" ref="model_promotion_program"/>
+ <field name="code">model.solr_flag_to_queue()</field>
+ <field name="state">code</field>
+ <field name="priority">55</field>
+ <field name="active">True</field>
+ </record>
+ </data>
</odoo> \ No newline at end of file