Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions base_multi_image/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

====================
Multiple Images Base
====================

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`, like
the ``product_multi_image`` module does::

from openerp.addons.base_multi_image.hooks import \
pre_init_hook_for_submodules


def pre_init_hook(cr):
pre_init_hook_for_submodules(cr, "product.template", "image")
pre_init_hook_for_submodules(cr, "product.product", "image_variant")


.. 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/9.0

Known issues / Roadmap
======================

* *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.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
server-tools/issues/new?body=module:%20
base_multi_image%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Original implementation
-----------------------
This module is inspired in previous module *product_images* from OpenLabs
and Akretion.

Contributors
------------

* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
* Sodexis <dev@sodexis.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
7 changes: 7 additions & 0 deletions base_multi_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
28 changes: 28 additions & 0 deletions base_multi_image/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# © 2016 Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Multiple images base",
"summary": "Allow multiple images for database objects",
"version": "9.0.1.0.0",
"author": "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Antiun Ingeniería, S.L., Sodexis, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "http://www.antiun.com",
"category": "Tools",
"depends": ['base'],
'installable': True,
"data": [
"security/ir.model.access.csv",
"views/image_view.xml",
],
"images": [
"images/form.png",
"images/kanban.png",
],
}
44 changes: 44 additions & 0 deletions base_multi_image/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, SUPERUSER_ID
import logging

_logger = logging.getLogger(__name__)


def pre_init_hook_for_submodules(cr, model, field):
"""Moves images from single to multi mode.

Feel free to use this as a ``pre_init_hook`` for submodules.

:param str model:
Model name, like ``product.template``.

:param str field:
Binary field that had the images in that :param:`model`, like
``image``.
"""
env = api.Environment(cr, SUPERUSER_ID, dict())
with cr.savepoint():
cr.execute(
"""
INSERT INTO base_multi_image_image (
owner_id,
owner_model,
storage,
file_db_store
)
SELECT
id,
%%s,
'db',
%(field)s
FROM
%(table)s
WHERE
%(field)s IS NOT NULL
""" % {"table": env[model]._table, "field": field},
(model,)
)
165 changes: 165 additions & 0 deletions base_multi_image/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_multi_image
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-12 02:05+0000\n"
"PO-Revision-Date: 2016-03-09 16:29+0000\n"
"Last-Translator: <>\n"
"Language-Team: German (http://www.transifex.com/oca/OCA-server-tools-8-0/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: base_multi_image
#: code:addons/base_multi_image/models/image.py:22
#: sql_constraint:base_multi_image.image:0
#, python-format
msgid "A document can have only one image with the same name."
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
#: field:base_multi_image.image,comments:0
msgid "Comments"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,create_uid:0
msgid "Created by"
msgstr "Erstellt von"

#. module: base_multi_image
#: field:base_multi_image.image,create_date:0
msgid "Created on"
msgstr "Erstellt am:"

#. module: base_multi_image
#: selection:base_multi_image.image,storage:0
msgid "Database"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,extension:0
msgid "File extension"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,filename:0
msgid "Filename"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,id:0 field:base_multi_image.owner,id:0
msgid "ID"
msgstr "ID"

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
msgid "Image"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,path:0 help:base_multi_image.image,path:0
msgid "Image path"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,url:0
msgid "Image remote URL"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,file_db_store:0
msgid "Image stored in database"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,name:0
msgid "Image title"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_tree_view
#: field:base_multi_image.owner,image_ids:0
msgid "Images"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,write_uid:0
msgid "Last Updated by"
msgstr "Zuletzt aktualisiert von"

#. module: base_multi_image
#: field:base_multi_image.image,write_date:0
msgid "Last Updated on"
msgstr "Zuletzt aktualisiert am"

#. module: base_multi_image
#: code:addons/base_multi_image/models/owner.py:73
#, python-format
msgid "Main image"
msgstr ""

#. module: base_multi_image
#: model:ir.actions.act_window,name:base_multi_image.image_action
#: model:ir.ui.menu,name:base_multi_image.image_menu
msgid "Multi images"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
msgid "Name"
msgstr "Name"

#. module: base_multi_image
#: selection:base_multi_image.image,storage:0
msgid "OS file"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
msgid "Options"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
#: field:base_multi_image.image,owner_id:0
msgid "Owner"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,owner_model:0
msgid "Owner model"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_form_view
msgid "Preview"
msgstr ""

#. module: base_multi_image
#: view:base_multi_image.image:base_multi_image.image_kanban_view
msgid "Product Images"
msgstr ""

#. module: base_multi_image
#: field:base_multi_image.image,sequence:0
msgid "Sequence"
msgstr "Reihenfolge"

#. module: base_multi_image
#: field:base_multi_image.image,storage:0
msgid "Storage"
msgstr ""

#. module: base_multi_image
#: selection:base_multi_image.image,storage:0
msgid "URL"
msgstr ""
Loading