diff --git a/product_multi_image/README.rst b/product_multi_image/README.rst index 8bbe41cb46a..d702a7cfe73 100644 --- a/product_multi_image/README.rst +++ b/product_multi_image/README.rst @@ -49,9 +49,8 @@ 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. +#. You can select for which variants you want to make the image available. 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. @@ -62,33 +61,16 @@ into account this behaviour: #. 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. + the variants where it 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/9.0 + the variants where it is used. 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 =========== diff --git a/product_multi_image/__manifest__.py b/product_multi_image/__manifest__.py index 39cde9757a6..25ea91ea45c 100644 --- a/product_multi_image/__manifest__.py +++ b/product_multi_image/__manifest__.py @@ -11,7 +11,8 @@ "Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/product-attribute", - "category": "Sales Management", + "category": "Product", + "summary": "Add multiple images for a product, a.k.a. an image gallery.", "post_init_hook": "post_init_hook", "uninstall_hook": "uninstall_hook", "depends": [ @@ -23,10 +24,4 @@ "views/product_template_view.xml", ], "installable": True, - "images": [ - "images/product.png", - "images/db.png", - "images/file.png", - "images/url.png", - ], } diff --git a/product_multi_image/hooks.py b/product_multi_image/hooks.py index fbe16e70c01..a0d8d371db0 100644 --- a/product_multi_image/hooks.py +++ b/product_multi_image/hooks.py @@ -14,12 +14,12 @@ _logger.info("Cannot import base_multi_image hooks") -def post_init_hook(cr, registry): - post_init_hook_for_submodules(cr, registry, "product.template", "image_1920") - post_init_hook_for_submodules(cr, registry, "product.product", "image_variant_1920") +def post_init_hook(env): + post_init_hook_for_submodules(env, "product.template", "image_1920") + post_init_hook_for_submodules(env, "product.product", "image_variant_1920") -def uninstall_hook(cr, registry): +def uninstall_hook(env): """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") + uninstall_hook_for_submodules(env, "product.template") + uninstall_hook_for_submodules(env, "product.product") diff --git a/product_multi_image/models/product_product.py b/product_multi_image/models/product_product.py index 0ae286842bd..5e7ec82a82a 100644 --- a/product_multi_image/models/product_product.py +++ b/product_multi_image/models/product_product.py @@ -15,8 +15,6 @@ class ProductProduct(models.Model): inverse="_inverse_image_ids", ) - # image, image_medium, image_small fields are not available since 13.0 - @api.depends( "product_tmpl_id", "product_tmpl_id.image_ids", diff --git a/product_multi_image/models/product_template.py b/product_multi_image/models/product_template.py index cd4fca3d790..8b5e66ab33e 100644 --- a/product_multi_image/models/product_template.py +++ b/product_multi_image/models/product_template.py @@ -8,5 +8,3 @@ class ProductTemplate(models.Model): _name = "product.template" _inherit = [_name, "base_multi_image.owner"] - - # image, image_medium, image_small fields are not available since 13.0 diff --git a/product_multi_image/tests/test_product_multi_image.py b/product_multi_image/tests/test_product_multi_image.py index d737dc7ab47..aec762cde55 100644 --- a/product_multi_image/tests/test_product_multi_image.py +++ b/product_multi_image/tests/test_product_multi_image.py @@ -8,8 +8,9 @@ class TestProductMultiImage(common.TransactionCase): - def setUp(self): - super().setUp() + @classmethod + def setUpClass(self): + super().setUpClass() self.transparent_image = ( # 1x1 Transparent GIF b"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ) @@ -204,7 +205,7 @@ def test_11_post_init_hook_template(self): def test_12_uninstall_hook_product(self): """It should remove ``image_ids`` associated with products.""" - hooks.uninstall_hook(self.env.cr, self.registry) + hooks.uninstall_hook(self.env.cr) images = self.env["base_multi_image.image"].search( [("owner_model", "=", "product.product")], ) @@ -212,7 +213,7 @@ def test_12_uninstall_hook_product(self): def test_13_uninstall_hook_template(self): """It should remove ``image_ids`` associated with templates.""" - hooks.uninstall_hook(self.env.cr, self.registry) + hooks.uninstall_hook(self.env.cr) images = self.env["base_multi_image.image"].search( [("owner_model", "=", "product.template")], )