Skip to content

Commit

Permalink
Merge PR #359 into 10.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jul 10, 2019
2 parents f4a33d0 + 17a18b9 commit ab78d90
Show file tree
Hide file tree
Showing 29 changed files with 1,409 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -21,6 +21,7 @@ addon | version | summary
[product_default_image](product_default_image/) | 10.0.1.0.0 | Apply default images to new and existing products.
[product_manufacturer](product_manufacturer/) | 10.0.1.0.0 | Product Manufacturers
[product_multi_category](product_multi_category/) | 10.0.1.0.0 | Product - Many Categories
[product_multi_image](product_multi_image/) | 10.0.1.0.0 | Multiple Images in Products
[product_pricelist_tier](product_pricelist_tier/) | 10.0.1.0.0 | Extends pricelists with tiered pricing.
[product_profile](product_profile/) | 10.0.1.0.0 | Allow to configure a product in 1 click
[product_profile_example](product_profile_example/) | 10.0.1.0.1 | Product Profile Use Case
Expand Down
14 changes: 11 additions & 3 deletions product_default_image/hooks.py
Expand Up @@ -10,9 +10,17 @@
def find_templates_with_imgs(cr, registry):
with cr.savepoint():
env = api.Environment(cr, SUPERUSER_ID, {})
tmpls = env['product.template'].search([
('image', '!=', False),
])
ProductTemplate = env['product.template']
if ProductTemplate._fields['image'].store:
tmpls = ProductTemplate.search([
('image', '!=', False),
])
else:
# some modules (like product_multi_image) could change image to
# non-store, so it is necessary to get all product templates and
# filter them
tmpls = ProductTemplate.search([])
tmpls = tmpls.filtered(lambda tmpl: tmpl.image)
tmpls.write({
'image_type': CUSTOM,
})
106 changes: 106 additions & 0 deletions product_multi_image/README.rst
@@ -0,0 +1,106 @@
.. 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 in Products
===========================

This module implements the possibility to have multiple images for a product
template, a.k.a. an image gallery.

Installation
============

To install this module, you need to:

* Install ``base_multi_image`` from
`OCA/server-tools <https://github.com/OCA/server-tools>`_.

Usage
=====

You can manage your images at Product template level:

#. Go to *Sales > Products > Products* and choose a product template.
#. Go to the *Images* tab.
#. Add a new image or edit the existing ones.
#. You can select for which variants you want to make available the image.
Keep it empty for making visible in all.
#. Refresh the page.
#. The first image in the collection is the main image for the product
template.

Going to product variants form, you can manage also your images, but take
into account this behaviour:

#. Go to *Sales > Products > Product Variants* and choose a product variant.
#. If you add an image here, the image is actually added to the product
template, and restricted to this variant.
#. When editing an existing image, the image is changed generally for all
the variants where is enabled, not only for this variant.
#. When removing an image from this form, if the image is only in this variant,
the image is removed. Otherwise, the image gets restricted to the rest of
the variants where is available.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/135/10.0

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

* When you change the image on the product variant, the preview image of the
*Images* tab doesn't get refreshed until you refresh the browser, or if you
go to its template, but the image has been actually saved!
* The field "Available in these variants" appears when opening the image
from the product variant.
* Add logic for handling to add images with the same name that another variant
of the same template, renaming the new image to a unique name.
* Add logic for handling to add the same image in several variants to a
already in another variant for not duplicating bytes.
* Provide proper migration scripts from module product_images from 7.0.
* Migrate to v8 api when https://github.com/odoo/odoo/issues/10799 gets fixed.
* If you try to sort images before saving the product variant or template, you
will get an error similar to ``DataError: invalid input syntax for integer:
"one2many_v_id_62"``. This bug has not been fixed yet, but a workaround is to
save and edit again to sort images.

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/product-attribute/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.

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>
* Dave Lasley <dave@laslabs.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 https://odoo-community.org.
5 changes: 5 additions & 0 deletions product_multi_image/__init__.py
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3).

from . import models
from .hooks import pre_init_hook, uninstall_hook
33 changes: 33 additions & 0 deletions product_multi_image/__manifest__.py
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Multiple Images in Products",
"version": "10.0.1.0.0",
"author": "Antiun Ingeniería, "
"Tecnativa, "
"LasLabs, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://www.tecnativa.com",
"category": "Sales Management",
"pre_init_hook": "pre_init_hook",
"uninstall_hook": "uninstall_hook",
"depends": [
"base_multi_image",
"product",
],
"data": [
'views/image_view.xml',
'views/product_template_view.xml',
],
'installable': True,
"images": [
"images/product.png",
"images/db.png",
"images/file.png",
"images/url.png",
],
}
24 changes: 24 additions & 0 deletions product_multi_image/hooks.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

try:
from openerp.addons.base_multi_image.hooks import (
pre_init_hook_for_submodules,
uninstall_hook_for_submodules,
)
except ImportError:
pass


def pre_init_hook(cr):
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",
field="image", field_medium="image_medium",
field_small="image_small")
uninstall_hook_for_submodules(cr, registry, "product.product")
96 changes: 96 additions & 0 deletions product_multi_image/i18n/es.po
@@ -0,0 +1,96 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_multi_image
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-04-26 18:40+0000\n"
"PO-Revision-Date: 2016-04-26 18:40+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_form_view
msgid "(keep empty for being visible for all variants)"
msgstr "(dejar vacío para hacerlo visible para todas las variantes)"

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
#, fuzzy
msgid "<i>Visible in all variants</i>"
msgstr "Visible en todas las variantes"

#. module: product_multi_image
#: model:ir.model.fields,help:product_multi_image.field_base_multi_image_image_product_variant_ids
#, fuzzy
msgid ""
"If you leave it empty, all variants will show this image. Selecting one or "
"several of the available variants, you restrict the availability of the "
"image to those variants."
msgstr ""
"Si lo deja vacío, todas las variantes mostrarán esta imagen. Seleccionando "
"una o más de las variantes disponibles, restringirá la disponibilidad de la "
"imagen a esas variantes."

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_ids
#: model:ir.ui.view,arch_db:product_multi_image.view_product_template_form_img_inh
msgid "Images"
msgstr "Imágenes"

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main
msgid "Main image"
msgstr "Imagen principal"

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main_medium
msgid "Medium image"
msgstr "Imagen media"

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_product_product
msgid "Product"
msgstr "Producto"

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_base_multi_image_image_product_variant_count
msgid "Product variant count"
msgstr "Nº de variantes"

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main_small
msgid "Small image"
msgstr "Imagen pequeña"

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
msgid "Visible in"
msgstr "Visible en"

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_base_multi_image_image_product_variant_ids
msgid "Visible in these variants"
msgstr "Visible en estas variantes"

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_base_multi_image_image
msgid "base_multi_image.image"
msgstr ""

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
msgid "variant(s)"
msgstr "variante(s)"
86 changes: 86 additions & 0 deletions product_multi_image/i18n/product_multi_image.pot
@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_multi_image
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_form_view
msgid "(keep empty for being visible for all variants)"
msgstr ""

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
msgid "<i>Visible in all variants</i>"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,help:product_multi_image.field_base_multi_image_image_product_variant_ids
msgid "If you leave it empty, all variants will show this image. Selecting one or several of the available variants, you restrict the availability of the image to those variants."
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_ids
#: model:ir.ui.view,arch_db:product_multi_image.view_product_template_form_img_inh
msgid "Images"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main
msgid "Main image"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main_medium
msgid "Medium image"
msgstr ""

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_product_product
msgid "Product"
msgstr ""

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_product_template
msgid "Product Template"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_base_multi_image_image_product_variant_count
msgid "Product variant count"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_product_product_image_main_small
msgid "Small image"
msgstr ""

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
msgid "Visible in"
msgstr ""

#. module: product_multi_image
#: model:ir.model.fields,field_description:product_multi_image.field_base_multi_image_image_product_variant_ids
msgid "Visible in these variants"
msgstr ""

#. module: product_multi_image
#: model:ir.model,name:product_multi_image.model_base_multi_image_image
msgid "base_multi_image.image"
msgstr ""

#. module: product_multi_image
#: model:ir.ui.view,arch_db:product_multi_image.image_kanban_view
msgid "variant(s)"
msgstr ""

0 comments on commit ab78d90

Please sign in to comment.