diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-05 09:50:23 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-05 09:50:23 +0700 |
| commit | fd802e74a981f93e232aea18a00ebc6399547028 (patch) | |
| tree | 169563246e5d7153b05a476f482d4493051b0baf | |
| parent | 957246b5836f94f3663230545467407740f10736 (diff) | |
push
| -rw-r--r-- | indoteknik_custom/models/ir_attachment.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/indoteknik_custom/models/ir_attachment.py b/indoteknik_custom/models/ir_attachment.py index 6417fa3f..1acd0848 100644 --- a/indoteknik_custom/models/ir_attachment.py +++ b/indoteknik_custom/models/ir_attachment.py @@ -20,9 +20,11 @@ class Attachment(models.Model): return True if attachment else False def api_image(self, model, field, id): - base_url = self.env['ir.config_parameter'].get_param('web.base.url') + if not id: + return None + base_url = self.env['ir.config_parameter'].get_param('web.base.url').rstrip('/') is_found = self.is_found(model, field, id) - return base_url + 'api/image/' + model + '/' + field + '/' + str(id) if is_found else '' + return f"{base_url}/api/image/{model}/{field}/{id}" if is_found else None def api_image_local(self, model, field, id): base_url = self.env['ir.config_parameter'].get_param('web.base.local_url') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 20402c84..42cab882 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -100,7 +100,7 @@ class ProductTemplate(models.Model): "product_rating_f": template.virtual_rating, "product_id_i": template.id, "image_s": self.env['ir.attachment'].api_image('product.template', 'image_512', template.id), - "image_carousel_ss": carousel_images, + "image_carousels_s": ' || '.join(carousel_images) # Gunakan pemisah yang unik 'image_mobile_s': self.env['ir.attachment'].api_image('product.template', 'image_256', template.id), "variant_total_i": template.product_variant_count, "stock_total_f": template.qty_stock_vendor, |
