EP-25: What is the Difference Between Image & Binary Field in Odoo 18 | Odoo 18 Development Tutorial
The two field definitions, image_1920 = fields.Image(string="Student Image") and image_1920 = fields.Binary(string="Student Image"), both serve the purpose of storing image data in an Odoo model, but they have some key differences in how they are intended to be used and how Odoo handles them by default.
Here's a breakdown of the distinctions:
fields.Image(string="Student Image")
Intended for Images: This field is specifically designed for storing image data. Odoo's framework and web interface are optimized to handle fields of this type as images.
Automatic Resizing (Optional): The fields.Image field often comes with built-in support (or easy configuration) for automatic image resizing to different standard sizes (e.g., thumbnails, small previews, large versions). You might see related fields like image_128, image_256, etc., being automatically populated or easily accessible. The max_width and max_height attributes in the field definition (as seen in some examples) control the maximum dimensions of the stored image.
Widget: When displayed in Odoo's forms and views, fields.Image will typically use the image widget by default, providing a user-friendly interface for uploading and viewing images.
Data Storage: Underneath, the image data is stored as a binary (base64 encoded) string in the database, similar to fields.Binary.
Convenience: It offers a more semantic way to define an image field, and Odoo often provides utilities and conventions around fields.Image for common image-related tasks.
fields.Binary(string="Student Image")
General Binary Data: This is a more general-purpose field for storing any kind of binary data, not just images. This could include documents (PDF, Word), audio files, videos, or any other type of file.
No Automatic Resizing: fields.Binary does not inherently provide automatic image resizing. You would need to implement such functionality manually if required.
Widget: The default widget for a fields.Binary field is a file upload control. To display an image stored in a fields.Binary field as an image in the user interface, you would typically need to explicitly specify the image widget in the view definition.
Flexibility: It's more flexible as it can handle various file types. However, you lose some of the image-specific conveniences offered by fields.Image.
Data Storage: Like fields.Image, the data is stored as a binary (base64 encoded) string in the database.
#Odoo18 #OdooDevelopment #BinaryVsImage #OdooTechnical #Odoo18Features #OdooTutorials #OdooDevTips #OdooRelease #ERPDevelopment #OdooCommunity
#Odoo18Development #Odoo18Technical #Odoo18Tutorial #ImageField #BinaryField #OdooERP #Odoo18NewFeatures #Odoo18Tips #OdooTraining #OdooDeveloper #Python #PostgreSQL #Database #SoftwareDevelopment #ERP #BusinessSoftware #Odoo18Community #OdooExperience
Connect With Us:
—————————————
➡ ️ Websitehttps://www.cybrosys.com/m/
➡ ️ Email: info@cybrosys.com
➡ ️ Twihttps://twitter.com/cybrosysosys
➡ ️ Lihttps://www.linkedin.com/company/cybrosys/brosys
➡ ️ https://www.facebook.com/cybrosystechnologiesnologies
➡ ️ https://www.instagram.com/cybrosystech/brosystech
➡ https://pinterest.com/cybrosys/ / cybrosys

