diff options
| -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() |
