Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Base Attachment Object Store

Entity: ir.attachment

Compute Method: _compute_internal_url

Inputs Method Outputs
  • name
  • mimetype
  • id
for rec in self:
            filename, extension = os.path.splitext(rec.name)
            # determine if the file is an image
            pfx = "/web/content"
            if rec.mimetype and rec.mimetype.startswith("image/"):
                pfx = "/web/image"

            if not extension:
                extension = mimetypes.guess_extension(rec.mimetype)
            rec.internal_url = f"{pfx}/{rec.id}/{filename}{extension}"

Back to entity