Vladislav Shepilov
5 years ago
11 changed files with 118 additions and 24 deletions
-
4base_multi_image/README.rst
-
2base_multi_image/__manifest__.py
-
36base_multi_image/models/image.py
-
1base_multi_image/models/owner.py
-
66base_multi_image/readme/CONFIGURE.rst
-
6base_multi_image/readme/CONTRIBUTORS.rst
-
4base_multi_image/readme/CREDITS.rst
-
2base_multi_image/readme/DESCRIPTION.rst
-
4base_multi_image/readme/INSTALL.rst
-
3base_multi_image/readme/ROADMAP.rst
-
14base_multi_image/views/image_view.xml
@ -0,0 +1,66 @@ |
|||||
|
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 ``pre_init_hook_for_submodules`` and |
||||
|
``uninstall_hook_for_submodules`` as detailed below. |
||||
|
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 `~.hooks.pre_init_hook_for_submodules` and |
||||
|
`~.hooks.uninstall_hook_for_submodules`, like the |
||||
|
``product_multi_image`` module does:: |
||||
|
|
||||
|
try: |
||||
|
from odoo.addons.base_multi_image.hooks import ( |
||||
|
pre_init_hook_for_submodules, |
||||
|
uninstall_hook_for_submodules, |
||||
|
) |
||||
|
except ImportError: |
||||
|
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") |
||||
|
|
||||
|
|
||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
||||
|
:alt: Try me on Runbot |
||||
|
:target: https://runbot.odoo-community.org/runbot/149/10.0 |
@ -0,0 +1,6 @@ |
|||||
|
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> |
||||
|
* Rafael Blasco <rafabn@antiun.com> |
||||
|
* Jairo Llopis <yajo.sk8@gmail.com> |
||||
|
* Sodexis <dev@sodexis.com> |
||||
|
* Dave Lasley <dave@laslabs.com> |
||||
|
* Shepilov Vladislav <shepilov.v@protonmail.com> |
@ -0,0 +1,4 @@ |
|||||
|
Original implementation |
||||
|
----------------------- |
||||
|
This module is inspired in previous module *product_images* from OpenLabs |
||||
|
and Akretion. |
@ -0,0 +1,2 @@ |
|||||
|
This module extends the functionality of any model to support multiple images |
||||
|
(a gallery) attached to it and allow you to manage them. |
@ -0,0 +1,4 @@ |
|||||
|
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. |
@ -0,0 +1,3 @@ |
|||||
|
* *OS file* storage mode for images is meant to provide a path where Odoo has |
||||
|
read access and the image is already found, **not for making the module store |
||||
|
images there**. It would be nice to add that feature though. |
Write
Preview
Loading…
Cancel
Save
Reference in new issue