diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-24 11:43:52 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-24 11:43:52 +0700 |
| commit | 2a3a0a7e88ef24456eeda070a7d74f1457efdb18 (patch) | |
| tree | 2bb4cd374d46b5d5e4fb6e32fe239c5ccc83daf4 /indoteknik_custom/models/ir_attachment.py | |
| parent | 287cf8497b4b6bb825870ee2b3d1b49d4c29ab6a (diff) | |
| parent | 646b9e22fc11f6f1d1b556761a3df2df61f8f59b (diff) | |
Merge branch 'release' into staging
Diffstat (limited to 'indoteknik_custom/models/ir_attachment.py')
| -rw-r--r-- | indoteknik_custom/models/ir_attachment.py | 15 |
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 |
