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 /indoteknik_custom/models/ir_attachment.py | |
| parent | 957246b5836f94f3663230545467407740f10736 (diff) | |
push
Diffstat (limited to 'indoteknik_custom/models/ir_attachment.py')
| -rw-r--r-- | indoteknik_custom/models/ir_attachment.py | 6 |
1 files changed, 4 insertions, 2 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') |
