diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-14 09:41:18 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-14 09:41:18 +0700 |
| commit | b603e5eca682c7d42d259d3432316ed28b41737f (patch) | |
| tree | 7764521755db971132584da63155d84130529f70 | |
| parent | ed310664434620cbcdb536fad3762199d154af9b (diff) | |
product pricelist solr
| -rw-r--r-- | indoteknik_custom/models/product_pricelist.py | 18 | ||||
| -rw-r--r-- | indoteknik_custom/views/product_pricelist.xml | 8 |
2 files changed, 20 insertions, 6 deletions
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index 95e63cf0..2053accc 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -24,16 +24,22 @@ class ProductPricelist(models.Model): remaining_time = (self.end_date - datetime.now()).total_seconds() remaining_time = round(remaining_time) return max(remaining_time, 0) - + + def update_product_solr_flag(self): + for item in self.item_ids: + item.product_id.product_tmpl_id.solr_flag = 2 + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { 'title': 'Notification', 'message': f'{len(self.item_ids)} produk akan diupdate ke SOLR' } + } class ProductPricelistItem(models.Model): _inherit = 'product.pricelist.item' manufacture_id = fields.Many2one('x_manufactures', string='Manufacture') - @api.onchange('fixed_price','price_discount') - def update_solr_flag(self): + @api.constrains('fixed_price','price_discount') + def update_product_solr_flag(self): for item in self: - if item.product_id.product_tmpl_id.solr_flag == 1: - item.product_id.product_tmpl_id.solr_flag = 2 -
\ No newline at end of file + item.product_id.product_tmpl_id.solr_flag = 2
\ No newline at end of file diff --git a/indoteknik_custom/views/product_pricelist.xml b/indoteknik_custom/views/product_pricelist.xml index 55139a24..34876cc4 100644 --- a/indoteknik_custom/views/product_pricelist.xml +++ b/indoteknik_custom/views/product_pricelist.xml @@ -25,4 +25,12 @@ </page> </field> </record> + + <record id="product_pricelist_sync_product_solr_ir_actions_server" model="ir.actions.server"> + <field name="name">Sync Product to SOLR</field> + <field name="model_id" ref="product.model_product_pricelist"/> + <field name="binding_model_id" ref="product.model_product_pricelist"/> + <field name="state">code</field> + <field name="code">action = records.update_product_solr_flag()</field> + </record> </odoo>
\ No newline at end of file |
