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.

176 lines
5.8 KiB

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