Ir al contenido
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Inicia sesión
  • Nederlands English (US) Español (AR)
  • Contáctanos
  • Inicio
  • Blog
  • Empleos
  • Contáctanos
Cafayate.Net
  • 0
  • 0
    • Inicio
    • Blog
    • Empleos
    • Contáctanos
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Inicia sesión
  • Contáctanos

Odoo Multiple Images Base

  • Todos los blogs
  • Tech Blog
  • Odoo Multiple Images Base
  • 5 de marzo de 2021 por
    Administrator

    This module extends the functionality of any model to support multiple images (a gallery) attached to it and allow you to manage them.

    Installation

    This module adds abstract models to work on. Its sole purpose is to serve as base for other modules that implement galleries, so if you install this one manually you will notice no change. You should install any other module based on this one and this will get installed automatically.

    Usage

    To manage all stored images, you need to:

    • Go to Settings > Technical > Multi images.

    … but you probably prefer to manage them from the forms supplied by submodules that inherit this behavior.

    Development

    To develop a module based on this one:

    • See module product_multi_image as an example.

    • You have to inherit model base_multi_image.owner to the model that needs the gallery:

      class MyOwner(models.Model):
          _name = "my.model.name"
          _inherit = ["my.model.name", "base_multi_image.owner"]
      
          # If you need this, you will need ``post_init_hook_for_submodules``
          old_image_field = fields.Binary(related="image_main", store=False)
      
    • Somewhere in the owner view, add:

      <field
          name="image_ids"
          nolabel="1"
          context="{
              'default_owner_model': 'my.model.name',
              'default_owner_id': id,
          }"
          mode="kanban"/>
      
    • If the model you are extending already had an image field, and you want to trick Odoo to make those images to multi-image mode, you will need to make use of the provided :meth:`~.hooks.pre_init_hook_for_submodules` and:meth:`~.hooks.uninstall_hook_for_submodules`, like the product_multi_image module does:

      try:
          from openerp.addons.base_multi_image.hooks import \
              pre_init_hook_for_submodules
      except:
          pass
      
      
      def pre_init_hook(cr):
          """Transform single into multi images."""
          pre_init_hook_for_submodules(cr, "product.template", "image")
          pre_init_hook_for_submodules(cr, "product.product", "image_variant")
      
      
      def uninstall_hook(cr, registry):
          """Remove multi images for models that no longer use them."""
          uninstall_hook_for_submodules(cr, registry, "product.template")
          uninstall_hook_for_submodules(cr, registry, "product.product")
      
    https://apps.openerp.com/apps/modules/9.0/base_multi_image/
    en Tech Blog
    Install HumHub on an Ubuntu Trusty with Nginx and MariaDB

    Diseñado para empresas

    Somos un equipo de personas apasionadas cuyo objetivo es mejorar la vida de todos a través de productos revolucionarios. Creamos grandes productos para resolver sus problemas empresariales. Nuestros productos están diseñados para pequeñas y medianas empresas dispuestas a optimizar su rendimiento.

    Contáctenos

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Síganos
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)