diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-03 15:39:41 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-03 15:39:41 +0700 |
| commit | 3307dcbdb37285bcd43a719a0ecbc1453e4af9df (patch) | |
| tree | 81103ea011c3689b3c52304ba1f3e05d31a55853 /fixco_custom/models/ir_attachment.py | |
| parent | 50054732da991bdd966f4fba879c33ee853879ff (diff) | |
upload payments
Diffstat (limited to 'fixco_custom/models/ir_attachment.py')
| -rw-r--r-- | fixco_custom/models/ir_attachment.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fixco_custom/models/ir_attachment.py b/fixco_custom/models/ir_attachment.py new file mode 100644 index 0000000..6417fa3 --- /dev/null +++ b/fixco_custom/models/ir_attachment.py @@ -0,0 +1,30 @@ +from odoo import api, fields, models, _ +import logging + +_logger = logging.getLogger(__name__) + + +class Attachment(models.Model): + _inherit = 'ir.attachment' + + @api.autovacuum + def _gc_file_store(self): + _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 '' + + def api_image_local(self, model, field, id): + base_url = self.env['ir.config_parameter'].get_param('web.base.local_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 |
