diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-03 17:40:36 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-03 17:40:36 +0700 |
| commit | 69c476bba84a7cb2b33e8b45bc1ea7d140333b2f (patch) | |
| tree | 3a923f83ce3445b63da8053ff1365e4872b3a75e | |
| parent | 083e4ab620edc20534992d6dd8b891796ecb35ce (diff) | |
add cache reset per brand
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 20 | ||||
| -rwxr-xr-x | indoteknik_custom/views/x_manufactures.xml | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index 24b64c14..1d215cf8 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -1,5 +1,7 @@ from odoo import models, fields, api +import logging +_logger = logging.getLogger(__name__) class XManufactures(models.Model): _name = 'x_manufactures' @@ -36,6 +38,24 @@ class XManufactures(models.Model): ], string="Jenis Produk") x_short_desc = fields.Text(string="Short Description") product_tmpl_ids = fields.One2many('product.template', 'x_manufacture', string='Product Templates') + cache_reset_status = fields.Selection([ + ('reset', 'Reset'), + ('done', 'Done') + ], string="Cache Reset") + + def cache_reset(self): + manufactures = self.env['x_manufactures'].search([ + ('cache_reset_status', '=', 'reset'), + ]) + for manufacture in manufactures: + products = self.env['product.template'].search([ + ('x_manufacture', '=', manufacture.id), + ('solr_flag', '=', 1), + ]) + for product in products: + product.solr_flag = 2 + _logger.info("Reset Solr Flag to 2 %s" % product.id) + manufacture.cache_reset_status = 'done' @api.onchange('x_name','image_promotion_1','image_promotion_2') def update_solr_flag(self): diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index e7e1b85d..d122c6c1 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -22,6 +22,7 @@ <field name="x_short_desc"/> <field name="x_manufacture_level"/> <field name="x_manufacture_service_center"/> + <field name="cache_reset_status"/> </tree> </field> </record> @@ -40,6 +41,7 @@ <field name="x_short_desc"/> <field name="x_manufacture_level"/> <field name="x_produk_aksesoris_sparepart"/> + <field name="cache_reset_status"/> </group> <group> <field name="x_logo_manufacture" widget="image"/> |
