From 69c476bba84a7cb2b33e8b45bc1ea7d140333b2f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 3 Jan 2023 17:40:36 +0700 Subject: add cache reset per brand --- indoteknik_custom/models/x_manufactures.py | 20 ++++++++++++++++++++ indoteknik_custom/views/x_manufactures.xml | 2 ++ 2 files changed, 22 insertions(+) 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 @@ + @@ -40,6 +41,7 @@ + -- cgit v1.2.3