diff options
Diffstat (limited to 'indoteknik_custom/models/solr')
| -rw-r--r-- | indoteknik_custom/models/solr/apache_solr_queue.py | 19 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 2 |
3 files changed, 14 insertions, 11 deletions
diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 1b51538f..3d6bd733 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -1,10 +1,10 @@ from odoo import models, fields from datetime import datetime, timedelta -import logging, time - +import logging, time, traceback # <-- tambah traceback _logger = logging.getLogger(__name__) + class ApacheSolrQueue(models.Model): _name = 'apache.solr.queue' @@ -19,6 +19,7 @@ class ApacheSolrQueue(models.Model): ], 'Execute Status') execute_date = fields.Datetime('Execute Date') description = fields.Text('Description') + log = fields.Text('Log') def _compute_display_name(self): for rec in self: @@ -39,7 +40,7 @@ class ApacheSolrQueue(models.Model): if elapsed_time > max_exec_time: break rec.execute_queue() - + def open_target_record(self): return { 'name': '', @@ -67,17 +68,21 @@ class ApacheSolrQueue(models.Model): if model_instance: getattr(model_instance, function_name)() rec.execute_status = 'success' + rec.log = traceback.format_exc() else: rec.execute_status = 'not_found' except Exception as e: - rec.description = e + # simpan error ringkas + traceback lengkap + rec.description = str(e) + rec.log = traceback.format_exc() rec.execute_status = 'failed' + rec.execute_date = datetime.utcnow() self.env.cr.commit() def create_unique(self, payload={}): count = self.search_count([ - ('res_model', '=', payload['res_model']), + ('res_model', '=', payload['res_model']), ('res_id', '=', payload['res_id']), ('function_name', '=', payload['function_name']), ('execute_status', '=', False) @@ -90,8 +95,6 @@ class ApacheSolrQueue(models.Model): ('execute_status', '=', 'success'), ('execute_date', '>=', (datetime.utcnow() - timedelta(days=days_after))), ], limit=limit) - + for rec in solr: rec.unlink() - - diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index d8bc3973..7260c3ca 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -69,9 +69,9 @@ class ProductProduct(models.Model): 'product_id_i': variant.id, 'template_id_i': variant.product_tmpl_id.id, 'image_s': ir_attachment.api_image('product.template', 'image_512', variant.product_tmpl_id.id), - 'image_carousel_s': [ir_attachment.api_image('image.carousel', 'image', carousel.id) for carousel in variant.product_tmpl_id.image_carousel_lines], + 'image_carousel_ss': [ir_attachment.api_image('image.carousel', 'image', carousel.id) for carousel in variant.product_tmpl_id.image_carousel_lines], 'image_mobile_s': ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id), - 'stock_total_f': variant.qty_stock_vendor, + 'stock_total_f': variant.qty_free_bandengan, 'weight_f': variant.weight, 'manufacture_id_i': variant.product_tmpl_id.x_manufacture.id or 0, 'manufacture_name_s': variant.product_tmpl_id.x_manufacture.x_name or '', diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index c4aefe19..a7beca12 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -59,9 +59,9 @@ class ProductTemplate(models.Model): solr_model = self.env['apache.solr'] for template in self: + voucher = None if template.x_manufacture: voucher = self.get_voucher_pastihemat(template.x_manufacture.id) - # Lakukan sesuatu dengan voucher variant_names = ', '.join([x.display_name or '' for x in template.product_variant_ids]) variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids]) |
