diff --git a/shopinvader_search_engine/models/se_index.py b/shopinvader_search_engine/models/se_index.py index 528b5bd44f..5544d8089d 100644 --- a/shopinvader_search_engine/models/se_index.py +++ b/shopinvader_search_engine/models/se_index.py @@ -32,10 +32,10 @@ def _check_model(self): ) for se_index in self: if ( - se_index.serialize_type == "shopinvader_category_exports" + se_index.serializer_type == "shopinvader_category_exports" and se_index.model_id != category_model ) or ( - se_index.serialize_type == "shopinvader_product_exports" + se_index.serializer_type == "shopinvader_product_exports" and se_index.model_id != product_model ): raise ValidationError(_("'Serializer Type' must match 'Model'")) diff --git a/shopinvader_search_engine/tools/category_serializer.py b/shopinvader_search_engine/tools/category_serializer.py index 7ee023f6a8..8b104a1569 100644 --- a/shopinvader_search_engine/tools/category_serializer.py +++ b/shopinvader_search_engine/tools/category_serializer.py @@ -1,9 +1,15 @@ # Copyright 2023 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.addons.search_engine_serializer_pydantic.tools.serializer import ( + PydanticModelSerializer, +) from odoo.addons.shopinvader_product.schemas.category import ShopinvaderCategory -class ProductCategoryShopinvaderSerializer: +class ProductCategoryShopinvaderSerializer(PydanticModelSerializer): + def get_model_class(self): + return ShopinvaderCategory + def serialize(self, record): return ShopinvaderCategory.from_shopinvader_category(record) diff --git a/shopinvader_search_engine/tools/product_serializer.py b/shopinvader_search_engine/tools/product_serializer.py index c40d0577ab..64f514a612 100644 --- a/shopinvader_search_engine/tools/product_serializer.py +++ b/shopinvader_search_engine/tools/product_serializer.py @@ -1,9 +1,14 @@ # Copyright 2023 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - +from odoo.addons.search_engine_serializer_pydantic.tools.serializer import ( + PydanticModelSerializer, +) from odoo.addons.shopinvader_product.schemas.product import ShopinvaderVariant -class ProductProductShopinvaderSerializer: +class ProductProductShopinvaderSerializer(PydanticModelSerializer): + def get_model_class(self): + return ShopinvaderVariant + def serialize(self, record): return ShopinvaderVariant.from_shopinvader_variant(record)