summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-13 02:15:44 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-07-13 02:15:44 +0000
commit1db54f85ccdc4372cca3478ec53e3c0992f93b17 (patch)
tree5acc7df451e7ac4a86974e5a2a862078cca808e9
parent17fd1072ccd6f2f74f73dd2e52ce7f0120adb3ce (diff)
parent3681206164462bcd6fe84808b7639c5994a9510f (diff)
Merged in feature/all-promotion (pull request #162)
Feature/all promotion
-rw-r--r--indoteknik_custom/models/solr/promotion_program.py15
-rw-r--r--indoteknik_custom/views/promotion/promotion_program.xml21
2 files changed, 36 insertions, 0 deletions
diff --git a/indoteknik_custom/models/solr/promotion_program.py b/indoteknik_custom/models/solr/promotion_program.py
index 0d417b3e..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),
@@ -66,3 +67,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