From fd802e74a981f93e232aea18a00ebc6399547028 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 5 May 2025 09:50:23 +0700 Subject: push --- indoteknik_custom/models/ir_attachment.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/ir_attachment.py') 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') -- cgit v1.2.3