summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-08-27 15:47:28 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-08-27 15:47:28 +0700
commit1788dc7a4142f69e076891267d6e0567edd02d2f (patch)
tree172cfacea12d6b2944b6e1bfe0ea26b775e227e0
parentfbf4071010149637fed008c581424137577ee67f (diff)
add error log
-rw-r--r--indoteknik_custom/models/solr/promotion_program_line.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py
index 64ad4209..a7459521 100644
--- a/indoteknik_custom/models/solr/promotion_program_line.py
+++ b/indoteknik_custom/models/solr/promotion_program_line.py
@@ -2,6 +2,9 @@ from odoo import models, api
from typing import Type
import pysolr
import json
+import logging
+
+_logger = logging.getLogger(__name__)
class PromotionProgramLine(models.Model):
_inherit = 'promotion.program.line'
@@ -19,9 +22,9 @@ class PromotionProgramLine(models.Model):
})
def _sync_to_solr(self):
- solr_model = self.env['apache.solr']
-
- for rec in self:
+ solr_model = self.env['apache.solr']
+ for rec in self:
+ try:
document = solr_model.get_doc(self._solr_schema, rec.id)
products = [{
@@ -37,10 +40,7 @@ class PromotionProgramLine(models.Model):
promotion_type = rec._res_promotion_type()
- # Gathering all categories
category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids]
-
- # Set sequence_i to None if rec.sequence is 0
sequence_value = None if rec.sequence == 0 else rec.sequence
document.update({
@@ -71,7 +71,16 @@ class PromotionProgramLine(models.Model):
})
self.solr().add([document])
- self.solr().commit()
+ self.solr().commit()
+
+ except Exception as e:
+ _logger.error(
+ "Failed to sync record %s (ID: %s) to Solr. Error: %s",
+ rec._name, rec.id, str(e),
+ exc_info=True # biar stack trace keluar
+ )
+ # opsional -> kalau mau hard fail:
+ # raise UserError(_("Sync to Solr failed for record %s: %s") % (rec.name, str(e)))
@api.model
def create(self, vals):