diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5681057b..010fb56d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,6 @@ exclude: | ^connector_algolia/| ^connector_elasticsearch/| ^connector_search_engine_serializer_ir_export/| - ^search_engine_image_thumbnail/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops ^setup/|/static/description/index\.html$| diff --git a/search_engine_image_thumbnail/README.rst b/search_engine_image_thumbnail/README.rst index 48331d34..977688b7 100644 --- a/search_engine_image_thumbnail/README.rst +++ b/search_engine_image_thumbnail/README.rst @@ -17,13 +17,13 @@ Search Engine Multi Image Thumbnail :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsearch--engine-lightgray.png?logo=github - :target: https://github.com/OCA/search-engine/tree/16.0/search_engine_image_thumbnail + :target: https://github.com/OCA/search-engine/tree/18.0/search_engine_image_thumbnail :alt: OCA/search-engine .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/search-engine-16-0/search-engine-16-0-search_engine_image_thumbnail + :target: https://translation.odoo-community.org/projects/search-engine-18-0/search-engine-18-0-search_engine_image_thumbnail :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/search-engine&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/search-engine&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -77,18 +77,18 @@ thumbnails from an image you want to index. Behind the scenes, this module extend the ``se.indexable.recor`` model by adding 2 new methods: -- ``_get_or_create_thumbnails_for_multi_images``: This method is used - to get or create thumbnails for a set of images. -- ``_get_or_create_thumbnails_for_image``: This method is used to get - or create thumbnails for a single image. +- ``_get_or_create_thumbnails_for_multi_images``: This method is used to + get or create thumbnails for a set of images. +- ``_get_or_create_thumbnails_for_image``: This method is used to get or + create thumbnails for a single image. Thanks to these methods, you can easily generate thumbnails for images stored into odoo through three different ways: -- A relational field referencing record inheriting from - ``fs.image.relation.mixin``. -- An odoo's Image field. -- An FSImage field. +- A relational field referencing record inheriting from + ``fs.image.relation.mixin``. +- An odoo's Image field. +- An FSImage field. The sizes of the thumbnails generated by these methods are configured through the creation of a new record into the ``se.thumbnail.size`` @@ -189,12 +189,11 @@ Changelog Bugfixes ^^^^^^^^ -- Add new config parameter on the search engine backend to allow the - user to specify if the serialization of a record should fail if - thumbnails are requested but no thumbnail sizes are defined for the - model and field for which it' requested. Defaults to False (i.e. - don't fail). - (`#176 `__) +- Add new config parameter on the search engine backend to allow the + user to specify if the serialization of a record should fail if + thumbnails are requested but no thumbnail sizes are defined for the + model and field for which it' requested. Defaults to False (i.e. don't + fail). (`#176 `__) 16.0.1.0.4 (2024-04-09) ----------------------- @@ -202,27 +201,26 @@ Bugfixes Bugfixes ^^^^^^^^ -- *Fixes image sizes lookups.* +- *Fixes image sizes lookups.* - When serializing a record and generating thumbnails, the thumbnail - sizes are looked up on the index. Prior to this change, only sizes - defined for the model associated with the current index were looked - up. This means that if you tried to serialize a nested record that - had an image field that was defined on a different model, the - thumbnail size was not found and an error was thrown. The lookup - method takes now the record for which the thumbnail is being - generated as an argument, so that the correct model can be used to - look up the thumbnail size. You still need to define the thumbnail - sizes for each model serialized in the index. + When serializing a record and generating thumbnails, the thumbnail + sizes are looked up on the index. Prior to this change, only sizes + defined for the model associated with the current index were looked + up. This means that if you tried to serialize a nested record that had + an image field that was defined on a different model, the thumbnail + size was not found and an error was thrown. The lookup method takes + now the record for which the thumbnail is being generated as an + argument, so that the correct model can be used to look up the + thumbnail size. You still need to define the thumbnail sizes for each + model serialized in the index. - *Fixes UI error when creating a new thumbnail size.* + *Fixes UI error when creating a new thumbnail size.* - When creating a new record, the UI was throwing an error. This was - due to the computations of the domain to apply to restrict the - choices of the possible image fields. When the record is new, no - model is set, so the domain for the field must be empty. This is now - handled correctly. - (`#174 `__) + When creating a new record, the UI was throwing an error. This was due + to the computations of the domain to apply to restrict the choices of + the possible image fields. When the record is new, no model is set, so + the domain for the field must be empty. This is now handled correctly. + (`#174 `__) Bug Tracker =========== @@ -230,7 +228,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -245,9 +243,9 @@ Authors Contributors ------------ -- Laurent Mignon laurent.mignon@acsone.eu (https://www.acsone.eu/) -- Mohamed Alkobrosli alkobroslymohamed@gmail.com - (https://www.kobros-tech.com/) +- Laurent Mignon laurent.mignon@acsone.eu (https://www.acsone.eu/) +- Mohamed Alkobrosli alkobroslymohamed@gmail.com + (https://www.kobros-tech.com/) Other credits ------------- @@ -277,6 +275,6 @@ Current `maintainer `__: |maintainer-lmignon| -This module is part of the `OCA/search-engine `_ project on GitHub. +This module is part of the `OCA/search-engine `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/search_engine_image_thumbnail/__manifest__.py b/search_engine_image_thumbnail/__manifest__.py index cc4abc4f..5a925103 100644 --- a/search_engine_image_thumbnail/__manifest__.py +++ b/search_engine_image_thumbnail/__manifest__.py @@ -3,9 +3,8 @@ { "name": "Search Engine Multi Image Thumbnail", - "summary": """ - Generate thumbnails for binded record""", - "version": "16.0.1.0.7", + "summary": "Generate thumbnails for binded record", + "version": "18.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/search-engine", @@ -29,6 +28,5 @@ "views/se_thumbnail.xml", "views/se_thumbnail_size.xml", ], - "demo": [], - "installable": False, + "installable": True, } diff --git a/search_engine_image_thumbnail/models/ir_attachment.py b/search_engine_image_thumbnail/models/ir_attachment.py index 14d656bd..a726ee4f 100644 --- a/search_engine_image_thumbnail/models/ir_attachment.py +++ b/search_engine_image_thumbnail/models/ir_attachment.py @@ -5,7 +5,6 @@ class IrAttachment(models.Model): - _inherit = "ir.attachment" se_thumbnail_ids = fields.One2many( diff --git a/search_engine_image_thumbnail/models/se_backend.py b/search_engine_image_thumbnail/models/se_backend.py index ba6fef81..5f98a3a0 100644 --- a/search_engine_image_thumbnail/models/se_backend.py +++ b/search_engine_image_thumbnail/models/se_backend.py @@ -5,7 +5,6 @@ class SeBackend(models.Model): - _inherit = "se.backend" image_field_thumbnail_size_ids = fields.One2many( diff --git a/search_engine_image_thumbnail/models/se_image_field_thumbnail_size.py b/search_engine_image_thumbnail/models/se_image_field_thumbnail_size.py index 414a2e58..752204d0 100644 --- a/search_engine_image_thumbnail/models/se_image_field_thumbnail_size.py +++ b/search_engine_image_thumbnail/models/se_image_field_thumbnail_size.py @@ -6,7 +6,6 @@ class SeImageFieldThumbnailSize(models.Model): - _name = "se.image.field.thumbnail.size" _description = "Index Thumbnail Size" diff --git a/search_engine_image_thumbnail/models/se_index.py b/search_engine_image_thumbnail/models/se_index.py index 28adbc5b..62c860f5 100644 --- a/search_engine_image_thumbnail/models/se_index.py +++ b/search_engine_image_thumbnail/models/se_index.py @@ -5,7 +5,6 @@ class SeIndex(models.Model): - _inherit = "se.index" image_field_thumbnail_size_ids = fields.One2many( diff --git a/search_engine_image_thumbnail/models/se_indexable_record.py b/search_engine_image_thumbnail/models/se_indexable_record.py index ef372f69..289bf5e8 100644 --- a/search_engine_image_thumbnail/models/se_indexable_record.py +++ b/search_engine_image_thumbnail/models/se_indexable_record.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from collections import OrderedDict -from odoo import _, fields, models +from odoo import fields, models from odoo.exceptions import UserError from odoo.addons.connector_search_engine.models.se_index import SeIndex @@ -32,7 +32,8 @@ def _get_or_create_thumbnails_for_multi_images( :param field_name: The name of the field :return: a ordered dictionary where the key is the original image relation and the value is a list of tuple(se.thumbnail.size, se.thumbnail) - (The order of the dict is the order of the images in the original Odoo record) + (The order of the dict is the order of the images in the original + Odoo record) """ self.ensure_one() @@ -48,7 +49,7 @@ def _get_or_create_thumbnails_for_multi_images( thumbnails_by_image = se_tumbnail_model.get_or_create_thumbnails( *images.mapped("image"), sizes=thumbnail_sizes_by_size.keys(), - base_name=self._get_image_url_key(index, field_name) + base_name=self._get_image_url_key(index, field_name), ) res = OrderedDict[ FsImageRelationMixin, list[tuple[SeThumbnailSize, FsImageThumbnailMixin]] @@ -69,7 +70,8 @@ def _get_or_create_thumbnails_for_image( """Create a thumbnail for an image field. :param index: The index where the record should be added - :param field_name: The name of the field. (should be a fields.Image or FSImage) field + :param field_name: The name of the field. (should be a fields.Image or + FSImage) field :return: a list of tuple(se.thumbnail.size, fs.image.thumbnail.mixi) """ thumbnail_sizes_by_size = self._get_thumbnail_sizes_by_size_for_field( @@ -114,7 +116,7 @@ def _get_thumbnail_sizes_by_size_for_field( sizes = index._get_thumbnail_sizes(self, field_name) if not sizes and index.backend_id.fails_if_no_thumbail_size: raise UserError( - _( + self.env._( "No thumbnail sizes defined for %(model)s.%(field)s", field=field_name, model=self._name, diff --git a/search_engine_image_thumbnail/models/se_thumbnail.py b/search_engine_image_thumbnail/models/se_thumbnail.py index bec37d58..d5d06f21 100644 --- a/search_engine_image_thumbnail/models/se_thumbnail.py +++ b/search_engine_image_thumbnail/models/se_thumbnail.py @@ -5,7 +5,6 @@ class SeThumbnail(models.Model): - _name = "se.thumbnail" _inherit = "fs.image.thumbnail.mixin" _description = "Indexed Image Thumbnail" diff --git a/search_engine_image_thumbnail/models/se_thumbnail_size.py b/search_engine_image_thumbnail/models/se_thumbnail_size.py index 770b2c40..1ed85e82 100644 --- a/search_engine_image_thumbnail/models/se_thumbnail_size.py +++ b/search_engine_image_thumbnail/models/se_thumbnail_size.py @@ -5,7 +5,6 @@ class SeThumbnailSize(models.Model): - _name = "se.thumbnail.size" _description = "Thumbnail Size" @@ -17,6 +16,4 @@ class SeThumbnailSize(models.Model): @api.depends("size_x", "size_y") def _compute_display_name(self): for record in self: - record.display_name = "{} ({}x{})".format( - record.name, record.size_x, record.size_y - ) + record.display_name = f"{record.name} ({record.size_x}x{record.size_y})" diff --git a/search_engine_image_thumbnail/pyproject.toml b/search_engine_image_thumbnail/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/search_engine_image_thumbnail/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/search_engine_image_thumbnail/security/se_image_field_thumbnail_size.xml b/search_engine_image_thumbnail/security/se_image_field_thumbnail_size.xml index c27a2acd..b7530a85 100644 --- a/search_engine_image_thumbnail/security/se_image_field_thumbnail_size.xml +++ b/search_engine_image_thumbnail/security/se_image_field_thumbnail_size.xml @@ -2,7 +2,6 @@ - se.image.field.thumbnail.size access read @@ -25,5 +24,4 @@ - diff --git a/search_engine_image_thumbnail/security/se_thumbnail.xml b/search_engine_image_thumbnail/security/se_thumbnail.xml index 85bb5cc8..8a21b31d 100644 --- a/search_engine_image_thumbnail/security/se_thumbnail.xml +++ b/search_engine_image_thumbnail/security/se_thumbnail.xml @@ -2,7 +2,6 @@ - se.thumbnail access read @@ -12,5 +11,4 @@ - diff --git a/search_engine_image_thumbnail/security/se_thumbnail_size.xml b/search_engine_image_thumbnail/security/se_thumbnail_size.xml index 5dc5e16a..1388db5e 100644 --- a/search_engine_image_thumbnail/security/se_thumbnail_size.xml +++ b/search_engine_image_thumbnail/security/se_thumbnail_size.xml @@ -2,7 +2,6 @@ - se.thumbnail.size access read @@ -25,5 +24,4 @@ - diff --git a/search_engine_image_thumbnail/static/description/index.html b/search_engine_image_thumbnail/static/description/index.html index 11766455..ce842de1 100644 --- a/search_engine_image_thumbnail/static/description/index.html +++ b/search_engine_image_thumbnail/static/description/index.html @@ -369,7 +369,7 @@

Search Engine Multi Image Thumbnail

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:2b3cfd55ee16e375d602f9abdc8ca8f4c4f705c79e9a75b5878005aa668ad16c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Alpha License: AGPL-3 OCA/search-engine Translate me on Weblate Try me on Runboat

+

Alpha License: AGPL-3 OCA/search-engine Translate me on Weblate Try me on Runboat

This module is a technical module with the purpose of easing the export of image thumbnails to a search engine index.

It extends the functionality of the connector_search_engine module @@ -435,10 +435,10 @@

Usage

Behind the scenes, this module extend the se.indexable.recor model by adding 2 new methods:

    -
  • _get_or_create_thumbnails_for_multi_images: This method is used -to get or create thumbnails for a set of images.
  • -
  • _get_or_create_thumbnails_for_image: This method is used to get -or create thumbnails for a single image.
  • +
  • _get_or_create_thumbnails_for_multi_images: This method is used to +get or create thumbnails for a set of images.
  • +
  • _get_or_create_thumbnails_for_image: This method is used to get or +create thumbnails for a single image.

Thanks to these methods, you can easily generate thumbnails for images stored into odoo through three different ways:

@@ -466,11 +466,11 @@

Usage

base_name is normalized before being used.

Here is an example of how to use these methods:

-from odoo import models, fields
-from odoo.addons.fs_imeage.fields import FSImage
+from odoo import models, fields
+from odoo.addons.fs_imeage.fields import FSImage
 
 
-class ProductImageRelation(models.Model):
+class ProductImageRelation(models.Model):
     _name = "product.image.relation"
     _inherit = ["fs.image.relation.mixin"]
 
@@ -482,7 +482,7 @@ 

Usage

) -class ProductProduct(models.Model): +class ProductProduct(models.Model): _name = "product.product" _inherit = ["se.indexable.record", "product.product"] @@ -544,9 +544,8 @@

Bugfixes

  • Add new config parameter on the search engine backend to allow the user to specify if the serialization of a record should fail if thumbnails are requested but no thumbnail sizes are defined for the -model and field for which it’ requested. Defaults to False (i.e. -don’t fail). -(#176)
  • +model and field for which it’ requested. Defaults to False (i.e. don’t +fail). (#176) @@ -559,19 +558,18 @@

    Bugfixes

    When serializing a record and generating thumbnails, the thumbnail sizes are looked up on the index. Prior to this change, only sizes defined for the model associated with the current index were looked -up. This means that if you tried to serialize a nested record that -had an image field that was defined on a different model, the -thumbnail size was not found and an error was thrown. The lookup -method takes now the record for which the thumbnail is being -generated as an argument, so that the correct model can be used to -look up the thumbnail size. You still need to define the thumbnail -sizes for each model serialized in the index.

    +up. This means that if you tried to serialize a nested record that had +an image field that was defined on a different model, the thumbnail +size was not found and an error was thrown. The lookup method takes +now the record for which the thumbnail is being generated as an +argument, so that the correct model can be used to look up the +thumbnail size. You still need to define the thumbnail sizes for each +model serialized in the index.

    Fixes UI error when creating a new thumbnail size.

    -

    When creating a new record, the UI was throwing an error. This was -due to the computations of the domain to apply to restrict the -choices of the possible image fields. When the record is new, no -model is set, so the domain for the field must be empty. This is now -handled correctly. +

    When creating a new record, the UI was throwing an error. This was due +to the computations of the domain to apply to restrict the choices of +the possible image fields. When the record is new, no model is set, so +the domain for the field must be empty. This is now handled correctly. (#174)

    @@ -583,7 +581,7 @@

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -618,7 +616,7 @@

    Maintainers

    promote its widespread use.

    Current maintainer:

    lmignon

    -

    This module is part of the OCA/search-engine project on GitHub.

    +

    This module is part of the OCA/search-engine project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/search_engine_image_thumbnail/tests/common.py b/search_engine_image_thumbnail/tests/common.py index 25ee8e20..d2a046a0 100644 --- a/search_engine_image_thumbnail/tests/common.py +++ b/search_engine_image_thumbnail/tests/common.py @@ -11,16 +11,15 @@ class TestSeMultiImageThumbnailCase(TestSeBackendCaseBase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.loader = FakeModelLoader(cls.env, cls.__module__) - cls.loader.backup_registry() + def setUp(self): + super().setUp() + self.loader = FakeModelLoader(self.env, self.__module__) + self.loader.backup_registry() from odoo.addons.connector_search_engine.tests.models import SeBackend, SeIndex from .models import TestFSImage, TestImage, TestImageRelation, TestMultiImage - cls.loader.update_registry( + self.loader.update_registry( ( SeIndex, SeBackend, @@ -30,62 +29,62 @@ def setUpClass(cls): TestMultiImage, ) ) - cls.backend = cls.env["se.backend"].create( + self.backend = self.env["se.backend"].create( {"name": "Fake SE", "tech_name": "fake_se", "backend_type": "fake"} ) # models - cls.test_multi_image_model = cls.env["test.multi.image"] - cls.test_image_model = cls.env["test.image"] - cls.test_fsimage_model = cls.env["test.fsimage"] - cls.test_image_relation = cls.env["test.image.relation"] + self.test_multi_image_model = self.env["test.multi.image"] + self.test_image_model = self.env["test.image"] + self.test_fsimage_model = self.env["test.fsimage"] + self.test_image_relation = self.env["test.image.relation"] # model ids - cls.test_multi_image_model_id = cls.env.ref( + self.test_multi_image_model_id = self.env.ref( "search_engine_image_thumbnail.model_test_multi_image" ).id - cls.test_image_model_id = cls.env.ref( + self.test_image_model_id = self.env.ref( "search_engine_image_thumbnail.model_test_image" ).id - cls.test_fsimage_model_id = cls.env.ref( + self.test_fsimage_model_id = self.env.ref( "search_engine_image_thumbnail.model_test_fsimage" ).id # field ids - cls.multi_images_field_id = cls.env.ref( + self.multi_images_field_id = self.env.ref( "search_engine_image_thumbnail.field_test_multi_image__image_ids" ).id - cls.image_field_id = cls.env.ref( + self.image_field_id = self.env.ref( "search_engine_image_thumbnail.field_test_image__image" ).id - cls.fsimage_field_id = cls.env.ref( + self.fsimage_field_id = self.env.ref( "search_engine_image_thumbnail.field_test_fsimage__image" ).id - cls.index_multi_image = cls.env["se.index"].create( + self.index_multi_image = self.env["se.index"].create( { - "name": "fake_index", - "backend_id": cls.backend.id, - "model_id": cls.test_multi_image_model_id, + "name": "fake_multi_image_index", + "backend_id": self.backend.id, + "model_id": self.test_multi_image_model_id, } ) - cls.index_image = cls.env["se.index"].create( + self.index_image = self.env["se.index"].create( { - "name": "fake_index", - "backend_id": cls.backend.id, - "model_id": cls.test_image_model_id, + "name": "fake_image_index", + "backend_id": self.backend.id, + "model_id": self.test_image_model_id, } ) - cls.index_fsimage = cls.env["se.index"].create( + self.index_fsimage = self.env["se.index"].create( { - "name": "fake_index", - "backend_id": cls.backend.id, - "model_id": cls.test_fsimage_model_id, + "name": "fake_fsimage_index", + "backend_id": self.backend.id, + "model_id": self.test_fsimage_model_id, } ) # create some thumbnail sizes (small and medium) - cls.size_small = cls.env["se.thumbnail.size"].create( + self.size_small = self.env["se.thumbnail.size"].create( { "name": "small", "key": "small", @@ -93,7 +92,7 @@ def setUpClass(cls): "size_y": 5, } ) - cls.size_medium = cls.env["se.thumbnail.size"].create( + self.size_medium = self.env["se.thumbnail.size"].create( { "name": "medium", "key": "medium", @@ -103,37 +102,37 @@ def setUpClass(cls): ) # create some thumbnail sizes (small and medium for each models) - cls.test_multi_image_size = cls.env["se.image.field.thumbnail.size"].create( + self.test_multi_image_size = self.env["se.image.field.thumbnail.size"].create( { - "model_id": cls.test_multi_image_model_id, - "field_id": cls.multi_images_field_id, - "backend_id": cls.backend.id, - "size_ids": [(6, 0, [cls.size_small.id, cls.size_medium.id])], + "model_id": self.test_multi_image_model_id, + "field_id": self.multi_images_field_id, + "backend_id": self.backend.id, + "size_ids": [(6, 0, [self.size_small.id, self.size_medium.id])], } ) - cls.test_image_size = cls.env["se.image.field.thumbnail.size"].create( + self.test_image_size = self.env["se.image.field.thumbnail.size"].create( { - "model_id": cls.test_image_model_id, - "field_id": cls.image_field_id, - "backend_id": cls.backend.id, - "size_ids": [(6, 0, [cls.size_small.id, cls.size_medium.id])], + "model_id": self.test_image_model_id, + "field_id": self.image_field_id, + "backend_id": self.backend.id, + "size_ids": [(6, 0, [self.size_small.id, self.size_medium.id])], } ) - cls.test_fsimage_size = cls.env["se.image.field.thumbnail.size"].create( + self.test_fsimage_size = self.env["se.image.field.thumbnail.size"].create( { - "model_id": cls.test_fsimage_model_id, - "field_id": cls.fsimage_field_id, - "backend_id": cls.backend.id, - "size_ids": [(6, 0, [cls.size_small.id, cls.size_medium.id])], + "model_id": self.test_fsimage_model_id, + "field_id": self.fsimage_field_id, + "backend_id": self.backend.id, + "size_ids": [(6, 0, [self.size_small.id, self.size_medium.id])], } ) # create some PNG images - cls.image_blank = cls._create_image(20, 20, color="#FFFFFF") - cls.image_black = cls._create_image(20, 20, color="#000000") + self.image_blank = self._create_image(20, 20, color="#FFFFFF") + self.image_black = self._create_image(20, 20, color="#000000") # create some records - cls.test_multi_image = cls.test_multi_image_model.create( + self.test_multi_image = self.test_multi_image_model.create( { "name": "test", "image_ids": [ @@ -143,7 +142,7 @@ def setUpClass(cls): { "specific_image": FSImageValue( name="blank.png", - value=cls.image_blank, + value=self.image_blank, ), "sequence": 2, }, @@ -154,7 +153,7 @@ def setUpClass(cls): { "specific_image": FSImageValue( name="black.png", - value=cls.image_black, + value=self.image_black, ), "sequence": 1, }, @@ -162,26 +161,25 @@ def setUpClass(cls): ], } ) - cls.test_image = cls.test_image_model.create( + self.test_image = self.test_image_model.create( { "name": "test Image", - "image": base64.b64encode(cls.image_blank), + "image": base64.b64encode(self.image_blank), } ) - cls.test_fsimage = cls.test_fsimage_model.create( + self.test_fsimage = self.test_fsimage_model.create( { "name": "test FSImage", "image": FSImageValue( name="blank.png", - value=cls.image_blank, + value=self.image_blank, ), } ) - @classmethod - def tearDownClass(cls): - cls.loader.restore_registry() - super().tearDownClass() + def tearDown(self): + self.loader.restore_registry() + super().tearDown() @classmethod def _create_image(cls, width, height, color="#4169E1", img_format="PNG"): diff --git a/search_engine_image_thumbnail/tests/models.py b/search_engine_image_thumbnail/tests/models.py index c70cedc4..4fba705f 100644 --- a/search_engine_image_thumbnail/tests/models.py +++ b/search_engine_image_thumbnail/tests/models.py @@ -8,7 +8,6 @@ class TestImageRelation(models.Model): - _name = "test.image.relation" _inherit = "fs.image.relation.mixin" _description = "Test Multi Image Thumbnail Image" @@ -21,7 +20,6 @@ class TestImageRelation(models.Model): class TestMultiImage(models.Model): - _name = "test.multi.image" _inherit = ["se.indexable.record"] _description = "Test Image Thumbnail" @@ -35,7 +33,6 @@ class TestMultiImage(models.Model): class TestImage(models.Model): - _name = "test.image" _inherit = ["se.indexable.record"] _description = "Test Image" @@ -45,7 +42,6 @@ class TestImage(models.Model): class TestFSImage(models.Model): - _name = "test.fsimage" _inherit = ["se.indexable.record"] _description = "Test FSImage" diff --git a/search_engine_image_thumbnail/views/ir_attachment.xml b/search_engine_image_thumbnail/views/ir_attachment.xml index facd2673..4f815526 100644 --- a/search_engine_image_thumbnail/views/ir_attachment.xml +++ b/search_engine_image_thumbnail/views/ir_attachment.xml @@ -2,7 +2,6 @@ - ir.attachment.form ir.attachment @@ -15,7 +14,4 @@ - - - diff --git a/search_engine_image_thumbnail/views/se_backend.xml b/search_engine_image_thumbnail/views/se_backend.xml index da663c26..1e5bc918 100644 --- a/search_engine_image_thumbnail/views/se_backend.xml +++ b/search_engine_image_thumbnail/views/se_backend.xml @@ -2,7 +2,6 @@ - se.backend.form se.backend @@ -25,5 +24,4 @@ - diff --git a/search_engine_image_thumbnail/views/se_image_field_thumbnail_size.xml b/search_engine_image_thumbnail/views/se_image_field_thumbnail_size.xml index 3e892cac..20edbdce 100644 --- a/search_engine_image_thumbnail/views/se_image_field_thumbnail_size.xml +++ b/search_engine_image_thumbnail/views/se_image_field_thumbnail_size.xml @@ -2,8 +2,6 @@ - - se.image.field.thumbnail.size.search se.image.field.thumbnail.size @@ -17,7 +15,8 @@ name="group_by_backend_id" domain="[]" context="{'group_by':'backend_id'}" - /> + - se.image.field.thumbnail.size.tree + se.image.field.thumbnail.size.list se.image.field.thumbnail.size - + - + Thumbnail Sizes se.image.field.thumbnail.size - tree,form + list,form [] {} @@ -56,5 +55,4 @@ - diff --git a/search_engine_image_thumbnail/views/se_index.xml b/search_engine_image_thumbnail/views/se_index.xml index 0bb7c7f6..8018c9fa 100644 --- a/search_engine_image_thumbnail/views/se_index.xml +++ b/search_engine_image_thumbnail/views/se_index.xml @@ -2,7 +2,6 @@ - se.index.form se.index @@ -24,5 +23,4 @@ - diff --git a/search_engine_image_thumbnail/views/se_menu.xml b/search_engine_image_thumbnail/views/se_menu.xml index be780de2..57672793 100644 --- a/search_engine_image_thumbnail/views/se_menu.xml +++ b/search_engine_image_thumbnail/views/se_menu.xml @@ -2,11 +2,9 @@ - Thumbnails - diff --git a/search_engine_image_thumbnail/views/se_thumbnail.xml b/search_engine_image_thumbnail/views/se_thumbnail.xml index 154f2559..9132b6c9 100644 --- a/search_engine_image_thumbnail/views/se_thumbnail.xml +++ b/search_engine_image_thumbnail/views/se_thumbnail.xml @@ -2,7 +2,6 @@ - se.thumbnail.form se.thumbnail @@ -10,7 +9,7 @@ name="inherit_id" ref="fs_image_thumbnail.fs_image_thumbnail_mixin_form_view" /> - primary + primary + Indexed Image Thumbnail + se.thumbnail - tree,form + list,form [] {} @@ -68,5 +68,4 @@ - diff --git a/search_engine_image_thumbnail/views/se_thumbnail_size.xml b/search_engine_image_thumbnail/views/se_thumbnail_size.xml index ec204305..2b6fcc6a 100644 --- a/search_engine_image_thumbnail/views/se_thumbnail_size.xml +++ b/search_engine_image_thumbnail/views/se_thumbnail_size.xml @@ -2,8 +2,6 @@ - - se.thumbnail.size.search se.thumbnail.size @@ -16,22 +14,22 @@ - se.thumbnail.size.tree + se.thumbnail.size.list se.thumbnail.size - + - + Thumbnail Sizes se.thumbnail.size - tree,form + list,form [] {} @@ -42,5 +40,4 @@ - diff --git a/test-requirements.txt b/test-requirements.txt index aff1b75a..62d214b2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,3 +5,5 @@ unidecode # tests vcrpy-unittest + +odoo-addon-fs_base_multi_image @ git+https://github.com/OCA/storage.git@refs/pull/624/head#subdirectory=fs_base_multi_image