Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
      • Get a Tailored Demo
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +32 2 290 34 90
    • Get a Tailored Demo
  • Pricing
  • Help
  1. APPS
  2. Extra Tools
  3. Search Engine Multi Image Thumbnail v 16.0
  4. Sales Conditions FAQ

Search Engine Multi Image Thumbnail

by ACSONE SA/NV https://github.com/OCA/search-engine , Odoo Community Association (OCA) https://github.com/OCA/search-engine
Odoo
v 16.0 Third Party 12
Download for v 16.0 Deploy on Odoo.sh
Apps purchases are linked to your Odoo account, please sign in or sign up first.
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Community Apps Dependencies Show
• Base Partition
• Connector Search Engine
• Fs Base Multi Image
• Fs Image Thumbnail
• Job Queue
• server configuration environment files
• Fs Image
• Fs File
• Base Attachment Object Store
• Filesystem Storage Backend
Lines of code 9706
Technical Name search_engine_image_thumbnail
LicenseAGPL-3
Websitehttps://github.com/OCA/search-engine
You bought this module and need support? Click here!

Search Engine Multi Image Thumbnail

Alpha License: AGPL-3 OCA/search-engine Translate me on Weblate Try me on Runboat

This module is a technical module with the purpose of easing the export of image thumbnails to a search engine index.

It extends the functionality of the connector_search_engine module by adding specialized methods that can be used to get and generate thumbnails from an image you want to index.

Important

This is an alpha version, the data model and design can change at any time without warning. Only for development or testing purpose, do not use in production. More details on development status

Table of contents

  • Use Cases / Context
  • Configuration
  • Usage
  • Changelog
    • 16.0.1.0.5 (2024-04-10)
      • Bugfixes
    • 16.0.1.0.4 (2024-04-09)
      • Bugfixes
  • Bug Tracker
  • Credits
    • Authors
    • Contributors
    • Other credits
    • Maintainers

Use Cases / Context

When you export images to an index, you may want to ensure that the images are exported in a format and size that is suitable for the application that will consume the index.

This module depends on the fs_image_thumdbnail module. This last one provides a method and a mixin used to generate thumbnails from a FSImageValue object.

Configuration

If you want to force the format of the generated thumbnail, you define a a configuration parameter into Odoo with the key fs_image_thumbnail.resize_format and the value PNG or JPEG or GIF or ICO. Otherwise, the format of the generated thumbnail will be the same as the format of the original image.

Usage

As specified, this module will not add any new features by itself once installed. As a developer, you can depend on this module to benefit from a set of specialized methods that can be used to get and generate thumbnails from an image you want to index.

Behind the scenes, this module extend the se.indexable.recor model by adding 2 new methods:

  • _get_or_create_thumbnails_for_multi_images: This method is used to get or create thumbnails for a set of images.
  • _get_or_create_thumbnails_for_image: This method is used to get or create thumbnails for a single image.

Thanks to these methods, you can easily generate thumbnails for images stored into odoo through three different ways:

  • A relational field referencing record inheriting from fs.image.relation.mixin.
  • An odoo’s Image field.
  • An FSImage field.

The sizes of the thumbnails generated by these methods are configured through the creation of a new record into the se.thumbnail.size model. This model allows you to define the size of thumbnails by search engine backend, model and field. For example, you can define that you want to generate thumbnails of size 100x100 for all the images stored into the product.template model and the image field when you export them to the opensearch_xyz backend. In this way, you can easily define different thumbnail sizes for different search engine backends, models and fields according to your needs.

Thumbnails are always retrieved and generated for one image and a specific base_name. The base name is used as a key to identify the thumbnails from an image related to a usage and also as base name for the file name of the thumbnails generated. By default, the base_name is computed from the display name of the record that contains the image to ensure a good SEO. To avoid problems with special characters, the base_name is normalized before being used.

Here is an example of how to use these methods:

from odoo import models, fields
from odoo.addons.fs_imeage.fields import FSImage


class ProductImageRelation(models.Model):
    _name = "product.image.relation"
    _inherit = ["fs.image.relation.mixin"]

    name = fields.Char(required=True)
    product_id = fields.Many2one(
        "product.product",
        required=True,
        ondelete="cascade",
    )


class ProductProduct(models.Model):
    _name = "product.product"
    _inherit = ["se.indexable.record", "product.product"]

    name = fields.Char(required=True)
    image = fields.Image(required=True)
    image_ids = fields.One2many(
        "product.image.relation",
        "product_id",
        string="Images",
    )
    fs_image = FSImage(required=True)



# A creation is always done for a given se.index record.
index = self.env["se.index"].browse(1)
product = self.env["product.product"].browse(1)

# Get or create thumbnails for a single image
for (thumbnail_size, thumbnail) in product._get_or_create_thumbnails_for_image(
    index,
    field_name="image",
    ):
    # Do something with the thumbnail
    print(f"Thumbnail  for image with size {thumbnail_size.display_name} "
        "is available at url {thumbnail.image.url}")

# Get or create thumbnails for a single image
for (thumbnail_size, thumbnail) in product._get_or_create_thumbnails_for_image(
    index,
    field_name="fs_image",
    ):
    # Do something with the thumbnail
    print(f"Thumbnail for fs_image with size {thumbnail_size.display_name} "
        "is available at url {thumbnail.image.url}")


# Get or create thumbnails for a set of images
thumbnails_by_image = product._get_or_create_thumbnails_for_multi_images(
    index,
    field_name="image_ids",
    )

for (image, thumbnails) in thumbnails_by_image.items():
    for (thumbnail_size, thumbnail) in thumbnails:
        # Do something with the thumbnail
        print(f"Thumbnail for image {image.name} with size "
            "{thumbnail_size.display_name} is available at url "
            "{thumbnail.image.url}")

Changelog

16.0.1.0.5 (2024-04-10)

Bugfixes

  • Add new config parameter on the search engine backend to allow the user to specify if the serialization of a record should fail if thumbnails are requested but no thumbnail sizes are defined for the model and field for which it’ requested. Defaults to False (i.e. don’t fail). (#176)

16.0.1.0.4 (2024-04-09)

Bugfixes

  • Fixes image sizes lookups.

    When serializing a record and generating thumbnails, the thumbnail sizes are looked up on the index. Prior to this change, only sizes defined for the model associated with the current index were looked up. This means that if you tried to serialize a nested record that had an image field that was defined on a different model, the thumbnail size was not found and an error was thrown. The lookup method takes now the record for which the thumbnail is being generated as an argument, so that the correct model can be used to look up the thumbnail size. You still need to define the thumbnail sizes for each model serialized in the index.

    Fixes UI error when creating a new thumbnail size.

    When creating a new record, the UI was throwing an error. This was due to the computations of the domain to apply to restrict the choices of the possible image fields. When the record is new, no model is set, so the domain for the field must be empty. This is now handled correctly. (#174)

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • ACSONE SA/NV

Contributors

  • Laurent Mignon laurent.mignon@acsone.eu (https://www.acsone.eu/)
  • Mohamed Alkobrosli alkobroslymohamed@gmail.com (https://www.kobros-tech.com/)

Other credits

The development of this module has been financially supported by:

-Alcyon Belux

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

lmignon

This module is part of the OCA/search-engine project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with