You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.1 KiB

  1. To manage all stored images, you need to:
  2. * Go to *Settings > Technical > Multi images*.
  3. ... but you probably prefer to manage them from the forms supplied by
  4. submodules that inherit this behavior.
  5. Development
  6. ===========
  7. To develop a module based on this one:
  8. * See module ``product_multi_image`` as an example.
  9. * You have to inherit model ``base_multi_image.owner`` to the model that needs
  10. the gallery::
  11. class MyOwner(models.Model):
  12. _name = "my.model.name"
  13. _inherit = ["my.model.name", "base_multi_image.owner"]
  14. # If you need this, you will need ``pre_init_hook_for_submodules`` and
  15. ``uninstall_hook_for_submodules`` as detailed below.
  16. old_image_field = fields.Binary(related="image_main", store=False)
  17. * Somewhere in the owner view, add::
  18. <field
  19. name="image_ids"
  20. nolabel="1"
  21. context="{
  22. 'default_owner_model': 'my.model.name',
  23. 'default_owner_id': id,
  24. }"
  25. mode="kanban"/>
  26. * If the model you are extending already had an image field, and you want to
  27. trick Odoo to make those images to multi-image mode, you will need to make
  28. use of the provided `~.hooks.pre_init_hook_for_submodules` and
  29. `~.hooks.uninstall_hook_for_submodules`, like the
  30. ``product_multi_image`` module does::
  31. try:
  32. from odoo.addons.base_multi_image.hooks import (
  33. pre_init_hook_for_submodules,
  34. uninstall_hook_for_submodules,
  35. )
  36. except ImportError:
  37. pass
  38. def pre_init_hook(cr):
  39. """Transform single into multi images."""
  40. pre_init_hook_for_submodules(cr, "product.template", "image")
  41. pre_init_hook_for_submodules(cr, "product.product", "image_variant")
  42. def uninstall_hook(cr, registry):
  43. """Remove multi images for models that no longer use them."""
  44. uninstall_hook_for_submodules(cr, registry, "product.template")
  45. uninstall_hook_for_submodules(cr, registry, "product.product")
  46. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  47. :alt: Try me on Runbot
  48. :target: https://runbot.odoo-community.org/runbot/149/10.0