diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-24 11:43:52 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-24 11:43:52 +0700 |
| commit | 2a3a0a7e88ef24456eeda070a7d74f1457efdb18 (patch) | |
| tree | 2bb4cd374d46b5d5e4fb6e32fe239c5ccc83daf4 /indoteknik_custom/models/stock_vendor.py | |
| parent | 287cf8497b4b6bb825870ee2b3d1b49d4c29ab6a (diff) | |
| parent | 646b9e22fc11f6f1d1b556761a3df2df61f8f59b (diff) | |
Merge branch 'release' into staging
Diffstat (limited to 'indoteknik_custom/models/stock_vendor.py')
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index 1a6b4a64..1e5bce16 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -11,27 +11,47 @@ 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'), + ]) + + templates = [] + for stock in stocks: + templates.append(stock.product_variant_id.product_tmpl_id) + # stock.cache_reset_status = 'done' + templates = list(dict.fromkeys(templates)) + + for template in templates: + if template.solr_flag == 1: + template.solr_flag = 2 + _logger.info('Update Solr Flag to 2 %s' % template.name) def update_product_template(self): updated_virtual_qty_product_template = self.env['ir.config_parameter'].search([('key', '=', 'updated_virtual_qty_product_template')], limit=1) updated_virtual_qty_product_template_value = int(updated_virtual_qty_product_template.value) - + limit = 10000 query = [('active', '=', True), ('type', '=', 'product')] templates = self.env['product.template'].search(query, limit=limit, offset=updated_virtual_qty_product_template_value) template_count = self.env['product.template'].search_count(query) - + if (updated_virtual_qty_product_template_value + limit) > template_count: updated_virtual_qty_product_template.value = '0' else: updated_virtual_qty_product_template.value = str(limit + updated_virtual_qty_product_template_value) - + for template in templates: 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 |
