diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-19 11:59:23 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-19 11:59:23 +0700 |
| commit | 74e22ea21d16389937fe8d571a475218fda7ffa5 (patch) | |
| tree | 1bdbfda91eb5ff75647c598d11900fa716946fc5 | |
| parent | 064a4c0462e68edf89eadee6b5bc7c6508fe30eb (diff) | |
add cache reset stock vendor
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 24 | ||||
| -rwxr-xr-x | 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 @@ <tree> <field name="quantity" widget="badge" decoration-primary="True"/> <field name="product_variant_id"/> + <field name="cache_reset_status"/> <field name="__last_update"/> </tree> </field> @@ -33,6 +34,7 @@ <group> <field name="product_variant_id"/> <field name="quantity" widget="badge" decoration-primary="True"/> + <field name="cache_reset_status"/> <field name="__last_update"/> </group> <group></group> |
