diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b2b0798f8c..21cbcb2d62 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,6 @@ exclude: | ^shopinvader_pos/| ^shopinvader_price_per_qty/| ^shopinvader_product_attribute_set/| - ^shopinvader_product_brand_tag/| ^shopinvader_product_manufactured_for/| ^shopinvader_product_media/| ^shopinvader_product_new/| diff --git a/setup/shopinvader_product_brand_tag/odoo/addons/shopinvader_product_brand_tag b/setup/shopinvader_product_brand_tag/odoo/addons/shopinvader_product_brand_tag new file mode 120000 index 0000000000..c6ba041931 --- /dev/null +++ b/setup/shopinvader_product_brand_tag/odoo/addons/shopinvader_product_brand_tag @@ -0,0 +1 @@ +../../../../shopinvader_product_brand_tag \ No newline at end of file diff --git a/setup/shopinvader_product_brand_tag/setup.py b/setup/shopinvader_product_brand_tag/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/shopinvader_product_brand_tag/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopinvader_product_brand_tag/__init__.py b/shopinvader_product_brand_tag/__init__.py index 0650744f6b..e69de29bb2 100644 --- a/shopinvader_product_brand_tag/__init__.py +++ b/shopinvader_product_brand_tag/__init__.py @@ -1 +0,0 @@ -from . import models diff --git a/shopinvader_product_brand_tag/__manifest__.py b/shopinvader_product_brand_tag/__manifest__.py index c07b6da850..9fd42fce3e 100644 --- a/shopinvader_product_brand_tag/__manifest__.py +++ b/shopinvader_product_brand_tag/__manifest__.py @@ -5,15 +5,13 @@ { "name": "Shopvinvader Product Brand Tag", "summary": "Index Product Brand Tags in Shopinvader", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "category": "e-Commerce", "website": "https://github.com/shopinvader/odoo-shopinvader", - "author": "Camptocamp", + "author": "Camptocamp,ACSONE SA/NV", "license": "AGPL-3", "depends": ["shopinvader_product_brand", "product_brand_tag"], - "data": [ - "data/ir_export_product_brand.xml", - "data/ir_export_product.xml", - ], - "installable": False, + "installable": True, + "external_dependencies": {"python": ["extendable_pydantic>=1.2.0"]}, + "development_status": "Alpha", } diff --git a/shopinvader_product_brand_tag/data/ir_export_product.xml b/shopinvader_product_brand_tag/data/ir_export_product.xml deleted file mode 100644 index 9ea8d253b8..0000000000 --- a/shopinvader_product_brand_tag/data/ir_export_product.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - shopinvader_brand_id/serialized_tag_ids - shopinvader_brand_id:brand/serialized_tag_ids:tag_ids - - - - diff --git a/shopinvader_product_brand_tag/data/ir_export_product_brand.xml b/shopinvader_product_brand_tag/data/ir_export_product_brand.xml deleted file mode 100644 index ed3f6e7bb8..0000000000 --- a/shopinvader_product_brand_tag/data/ir_export_product_brand.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - tag_ids/id - tag_ids:tags/id - - - - - tag_ids/name - tag_ids:tags/name - - - - diff --git a/shopinvader_product_brand_tag/models/__init__.py b/shopinvader_product_brand_tag/models/__init__.py deleted file mode 100644 index a506ebbd37..0000000000 --- a/shopinvader_product_brand_tag/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import shopinvader_brand diff --git a/shopinvader_product_brand_tag/models/shopinvader_brand.py b/shopinvader_product_brand_tag/models/shopinvader_brand.py deleted file mode 100644 index 2df310563b..0000000000 --- a/shopinvader_product_brand_tag/models/shopinvader_brand.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2021 Camptocamp (https://www.camptocamp.com). -# @author Iván Todorovich -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import api, models - -from odoo.addons.base_sparse_field.models.fields import Serialized - - -class ShopinvaderBrand(models.Model): - _inherit = "shopinvader.brand" - - serialized_tag_ids = Serialized(compute="_compute_serialized_tag_ids") - - @api.depends("tag_ids") - def _compute_serialized_tag_ids(self): - for rec in self: - rec.serialized_tag_ids = rec.tag_ids.ids diff --git a/shopinvader_product_brand_tag/readme/CONTRIBUTORS.rst b/shopinvader_product_brand_tag/readme/CONTRIBUTORS.rst index c489224018..7359ed543a 100644 --- a/shopinvader_product_brand_tag/readme/CONTRIBUTORS.rst +++ b/shopinvader_product_brand_tag/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Camptocamp `_ * Iván Todorovich +* Marie Lejeune diff --git a/shopinvader_product_brand_tag/schemas/__init__.py b/shopinvader_product_brand_tag/schemas/__init__.py new file mode 100644 index 0000000000..0928590506 --- /dev/null +++ b/shopinvader_product_brand_tag/schemas/__init__.py @@ -0,0 +1,2 @@ +from .brand import ProductBrand +from .brand_tag import ProductBrandTag diff --git a/shopinvader_product_brand_tag/schemas/brand.py b/shopinvader_product_brand_tag/schemas/brand.py new file mode 100644 index 0000000000..0e0b44a4c1 --- /dev/null +++ b/shopinvader_product_brand_tag/schemas/brand.py @@ -0,0 +1,20 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.shopinvader_product_brand.schemas import ( + ProductBrand as BaseProductBrand, +) + +from . import ProductBrandTag + + +class ProductBrand(BaseProductBrand): + tags: list[ProductBrandTag] = [] + + @classmethod + def from_product_brand(cls, odoo_rec): + obj = super().from_product_brand(odoo_rec) + obj.tags = [ + ProductBrandTag.from_product_brand_tag(tag) for tag in odoo_rec.tag_ids + ] + return obj diff --git a/shopinvader_product_brand_tag/schemas/brand_tag.py b/shopinvader_product_brand_tag/schemas/brand_tag.py new file mode 100644 index 0000000000..ec59dcb565 --- /dev/null +++ b/shopinvader_product_brand_tag/schemas/brand_tag.py @@ -0,0 +1,13 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from extendable_pydantic import StrictExtendableBaseModel + + +class ProductBrandTag(StrictExtendableBaseModel): + id: int + name: str + + @classmethod + def from_product_brand_tag(cls, odoo_rec): + return cls.model_construct(id=odoo_rec.id, name=odoo_rec.name)