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.

139 lines
4.3 KiB

  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  3. :alt: License: AGPL-3
  4. ====================
  5. Multiple Images Base
  6. ====================
  7. This module extends the functionality of any model to support multiple images
  8. (a gallery) attached to it and allow you to manage them.
  9. Installation
  10. ============
  11. This module adds abstract models to work on. Its sole purpose is to serve as
  12. base for other modules that implement galleries, so if you install this one
  13. manually you will notice no change. You should install any other module based
  14. on this one and this will get installed automatically.
  15. Usage
  16. =====
  17. To manage all stored images, you need to:
  18. * Go to *Settings > Technical > Multi images*.
  19. ... but you probably prefer to manage them from the forms supplied by
  20. submodules that inherit this behavior.
  21. Development
  22. ===========
  23. To develop a module based on this one:
  24. * See module ``product_multi_image`` as an example.
  25. * You have to inherit model ``base_multi_image.owner`` to the model that needs
  26. the gallery::
  27. class MyOwner(models.Model):
  28. _name = "my.model.name"
  29. _inherit = ["my.model.name", "base_multi_image.owner"]
  30. # If you need this, you will need ``pre_init_hook_for_submodules`` and
  31. ``uninstall_hook_for_submodules`` as detailed below.
  32. old_image_field = fields.Binary(related="image_main", store=False)
  33. * Somewhere in the owner view, add::
  34. <field
  35. name="image_ids"
  36. nolabel="1"
  37. context="{
  38. 'default_owner_model': 'my.model.name',
  39. 'default_owner_id': id,
  40. }"
  41. mode="kanban"/>
  42. * If the model you are extending already had an image field, and you want to
  43. trick Odoo to make those images to multi-image mode, you will need to make
  44. use of the provided :meth:`~.hooks.pre_init_hook_for_submodules` and
  45. :meth:`~.hooks.uninstall_hook_for_submodules`, like the
  46. ``product_multi_image`` module does::
  47. try:
  48. from openerp.addons.base_multi_image.hooks import (
  49. pre_init_hook_for_submodules,
  50. uninstall_hook_for_submodules,
  51. )
  52. except ImportError:
  53. pass
  54. def pre_init_hook(cr):
  55. """Transform single into multi images."""
  56. pre_init_hook_for_submodules(cr, "product.template", "image")
  57. pre_init_hook_for_submodules(cr, "product.product", "image_variant")
  58. def uninstall_hook(cr, registry):
  59. """Remove multi images for models that no longer use them."""
  60. uninstall_hook_for_submodules(cr, registry, "product.template")
  61. uninstall_hook_for_submodules(cr, registry, "product.product")
  62. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  63. :alt: Try me on Runbot
  64. :target: https://runbot.odoo-community.org/runbot/149/9.0
  65. Known issues / Roadmap
  66. ======================
  67. * *OS file* storage mode for images is meant to provide a path where Odoo has
  68. read access and the image is already found, **not for making the module store
  69. images there**. It would be nice to add that feature though.
  70. Bug Tracker
  71. ===========
  72. Bugs are tracked on `GitHub Issues
  73. <https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
  74. check there if your issue has already been reported. If you spotted it first,
  75. help us smashing it by providing a detailed and welcomed `feedback
  76. <https://github.com/OCA/
  77. server-tools/issues/new?body=module:%20
  78. base_multi_image%0Aversion:%20
  79. 9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  80. Credits
  81. =======
  82. Original implementation
  83. -----------------------
  84. This module is inspired in previous module *product_images* from OpenLabs
  85. and Akretion.
  86. Contributors
  87. ------------
  88. * Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
  89. * Rafael Blasco <rafabn@antiun.com>
  90. * Jairo Llopis <yajo.sk8@gmail.com>
  91. * Sodexis <dev@sodexis.com>
  92. * Dave Lasley <dave@laslabs.com>
  93. Maintainer
  94. ----------
  95. .. image:: https://odoo-community.org/logo.png
  96. :alt: Odoo Community Association
  97. :target: https://odoo-community.org
  98. This module is maintained by the OCA.
  99. OCA, or the Odoo Community Association, is a nonprofit organization whose
  100. mission is to support the collaborative development of Odoo features and
  101. promote its widespread use.
  102. To contribute to this module, please visit http://odoo-community.org.