summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-01-23 14:44:12 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-01-23 14:44:12 +0700
commit8af5ee591aabc2d5d946c0eece93a5caab989975 (patch)
treea81740fff5f248bd4dd6b190f8650cdfa8849b47 /indoteknik_custom/models
parent4bc68435bc20d7da0f38bd2370057481cb995584 (diff)
Fix get api image logic
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/ir_attachment.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/indoteknik_custom/models/ir_attachment.py b/indoteknik_custom/models/ir_attachment.py
index 278eb938..fd86ab1b 100644
--- a/indoteknik_custom/models/ir_attachment.py
+++ b/indoteknik_custom/models/ir_attachment.py
@@ -9,4 +9,17 @@ class Attachment(models.Model):
@api.autovacuum
def _gc_file_store(self):
- _logger.info("filestore gc checked, removed - override") \ No newline at end of file
+ _logger.info("filestore gc checked, removed - override")
+
+ def is_found(self, model, field, id):
+ attachment = self.search([
+ ('res_model', '=', model),
+ ('res_field', '=', field),
+ ('res_id', '=', int(id))
+ ])
+ 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')
+ is_found = self.is_found(model, field, id)
+ return base_url + 'api/image/' + model + '/' + field + '/' + str(id) if is_found else '' \ No newline at end of file