diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 13:20:54 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-26 13:20:54 +0700 |
| commit | aec3028acc08c573b68a71b0144558f8fc091607 (patch) | |
| tree | 432c9c1e49264e366e697c087b6c9bdd8aa0b052 | |
| parent | e24d74a1ca5af90086060374dddc309e102579ea (diff) | |
Add solr flag and add to queue on program line
4 files changed, 32 insertions, 5 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index ce46d2e7..cb231889 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -30,7 +30,8 @@ class PromotionProgramLine(models.Model): discount_amount = fields.Float('Discount Amount') order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') - active = fields.Boolean(default=True) + active = fields.Boolean(string="Active", default=True) + solr_flag = fields.Integer(string="Solr Flag", default=1) def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 30ce16c9..b241b248 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -54,9 +54,7 @@ class PromotionProgramLine(models.Model): 'total_qty_i': sum([x.qty for x in rec.product_ids] + [x.qty for x in rec.free_product_ids]), 'active': 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 diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 7577e569..4c145b9f 100644 --- a/indoteknik_custom/views/apache_solr_queue.xml +++ b/indoteknik_custom/views/apache_solr_queue.xml @@ -4,13 +4,16 @@ <field name="model">apache.solr.queue</field> <field name="arch" type="xml"> <tree editable="top" default_order="create_date desc"> - <button type="object" name="open_target_record" class="fa fa-external-link" /> + <button type="object" name="open_target_record" string="" icon="fa-external-link" /> <field name="id" readonly="1" /> <field name="display_name" readonly="1" /> <field name="res_model" readonly="1" /> <field name="res_id" readonly="1" /> <field name="function_name" readonly="1" /> - <field name="execute_status" widget="badge" readonly="1" + <field + name="execute_status" + widget="badge" + readonly="1" decoration-danger="execute_status == 'failed'" decoration-success="execute_status == 'success'" decoration-primary="execute_status == 'not_found'" diff --git a/indoteknik_custom/views/promotion/promotion_program_line.xml b/indoteknik_custom/views/promotion/promotion_program_line.xml index 280bdfba..4bc737b9 100644 --- a/indoteknik_custom/views/promotion/promotion_program_line.xml +++ b/indoteknik_custom/views/promotion/promotion_program_line.xml @@ -71,4 +71,19 @@ sequence="2" action="promotion_program_line_action" /> + + <data noupdate="1"> + <record id="cron_program_line_solr_flag_solr" model="ir.cron"> + <field name="name">Program Line: 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_line"/> + <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 |
