From 74e22ea21d16389937fe8d571a475218fda7ffa5 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 19 Jan 2023 11:59:23 +0700 Subject: add cache reset stock vendor --- indoteknik_custom/models/stock_vendor.py | 24 +++++++++++++++++++----- indoteknik_custom/views/stock_vendor.xml | 2 ++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index 1a6b4a64..07b0e5b6 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -11,6 +11,20 @@ class StockVendor(models.Model): product_variant_id = fields.Many2one("product.product", string="Product Variant") quantity = fields.Integer(string="Quantity") + cache_reset_status = fields.Selection([ + ('reset', 'Reset'), + ('done', 'Done') + ], string="Cache Reset") + + def cache_reset(self): + stocks = self.env['stock.vendor'].search([ + ('cache_reset_status', '=', 'reset'), + ]) + for stock in stocks: + if stock.product_variant_id.product_tmpl_id.solr_flag == 1: + stock.product_variant_id.product_tmpl_id.solr_flag = 2 + _logger.info('Update Solr Flag to 2 %s' % stock.product_variant_id.product_tmpl_id.name) + stock.cache_reset_status = 'done' def update_product_template(self): updated_virtual_qty_product_template = self.env['ir.config_parameter'].search([('key', '=', 'updated_virtual_qty_product_template')], limit=1) @@ -30,8 +44,8 @@ class StockVendor(models.Model): template.virtual_qty = template.qty_stock_vendor or 0 _logger.info("Update Stock Product Template %s : %s" % (template.id, template.virtual_qty)) - @api.onchange('quantity') - def update_solr_flag(self): - for stock in self: - if stock.product_variant_id.product_tmpl_id.solr_flag == 1: - stock.product_variant_id.product_tmpl_id.solr_flag = 2 + # @api.onchange('quantity') + # def update_solr_flag(self): + # for stock in self: + # if stock.product_variant_id.product_tmpl_id.solr_flag == 1: + # stock.product_variant_id.product_tmpl_id.solr_flag = 2 diff --git a/indoteknik_custom/views/stock_vendor.xml b/indoteknik_custom/views/stock_vendor.xml index ebf63a6a..35931750 100755 --- a/indoteknik_custom/views/stock_vendor.xml +++ b/indoteknik_custom/views/stock_vendor.xml @@ -18,6 +18,7 @@ + @@ -33,6 +34,7 @@ + -- cgit v1.2.3