diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-09 15:43:46 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-09 15:43:46 +0700 |
| commit | ed540db853df349df9739706159adcc209b971d8 (patch) | |
| tree | 9dc0f8778b7a242dc9bade7a40090fbe89600c40 | |
| parent | e754783d3ea683765f8ff31df84c633bf5f85751 (diff) | |
test product rating with fieldUpdates
| -rw-r--r-- | indoteknik_custom/models/apache_solr.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/indoteknik_custom/models/apache_solr.py b/indoteknik_custom/models/apache_solr.py index 7f8ed97a..54b87751 100644 --- a/indoteknik_custom/models/apache_solr.py +++ b/indoteknik_custom/models/apache_solr.py @@ -42,29 +42,29 @@ class ApacheSolr(models.Model): current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') - query = [ - '&','&', - ('type', '=', 'product'), - ('active', '=', True), - '|', - ('last_calculate_rating', '=', False), - ('last_calculate_rating', '<', delta_time), - ] - # query = [('id', '=', 97942)] + # query = [ + # '&','&', + # ('type', '=', 'product'), + # ('active', '=', True), + # '|', + # ('last_calculate_rating', '=', False), + # ('last_calculate_rating', '<', delta_time), + # ] + query = [('id', '=', 97942)] templates = self.env['product.template'].search(query, limit=limit) documents=[] for template in templates: rating = int(template.virtual_rating) - dict_rating = dict({'set':rating}) + # dict_rating = dict({'set':rating}) document = { 'id':template.id, - 'product_rating_f':dict_rating + 'product_rating_f':rating } documents.append(document) template.last_calculate_rating = current_time _logger.info("[SYNC_PRODUCT_RATING_TO_SOLR] Success Set to solr product %s" % template.id) - _solr.add(document) _logger.info(documents) + _solr.add(documents, fieldUpdates={'product_rating_f':'set'}) def _sync_product_to_solr(self, limit=500): start_time = time.time() |
