summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-19 11:59:23 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-19 11:59:23 +0700
commit74e22ea21d16389937fe8d571a475218fda7ffa5 (patch)
tree1bdbfda91eb5ff75647c598d11900fa716946fc5 /indoteknik_custom/models
parent064a4c0462e68edf89eadee6b5bc7c6508fe30eb (diff)
add cache reset stock vendor
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/stock_vendor.py24
1 files changed, 19 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