Skip to content

Commit

Permalink
[MIG] shopinvader_product_media: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
qgroulard committed Aug 10, 2023
1 parent 6fa829e commit a1999b5
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 33 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exclude: |
^shopinvader_product_brand_image/|
^shopinvader_product_brand_tag/|
^shopinvader_product_manufactured_for/|
^shopinvader_product_media/|
^shopinvader_product_new/|
^shopinvader_product_order/|
^shopinvader_product_price_tax/|
Expand Down
6 changes: 6 additions & 0 deletions setup/shopinvader_product_media/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
1 change: 1 addition & 0 deletions shopinvader_product_media/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import schemas
8 changes: 4 additions & 4 deletions shopinvader_product_media/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{
"name": "Shopinvader Product Media",
"summary": "Index storage media data into external search engine",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"category": "e-commerce",
"website": "https://github.com/shopinvader/odoo-shopinvader",
"author": "Akretion",
"license": "AGPL-3",
"installable": False,
"installable": True,
"auto_install": True,
"depends": ["shopinvader", "storage_media_product"],
"data": ["data/ir_product_export.xml"],
"depends": ["shopinvader_product", "storage_media_product"],
"data": [],
}
28 changes: 0 additions & 28 deletions shopinvader_product_media/data/ir_product_export.xml

This file was deleted.

1 change: 1 addition & 0 deletions shopinvader_product_media/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product
47 changes: 47 additions & 0 deletions shopinvader_product_media/schemas/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.addons.extendable_fastapi import StrictExtendableBaseModel
from odoo.addons.shopinvader_product.schemas.product import (
ShopinvaderVariant as BaseShopinvaderVariant,
)


class ShopinvaderProductMediaType(StrictExtendableBaseModel):
name: str
code: str | None = None

@classmethod
def from_shopinvader_product_media_type(cls, odoo_rec):
return cls.model_construct(name=odoo_rec.name, code=odoo_rec.code or None)


class ShopinvaderProductMedia(StrictExtendableBaseModel):
name: str
url: str | None = None
type: ShopinvaderProductMediaType | None = None

@classmethod
def from_shopinvader_product_media(cls, odoo_rec):
return cls.model_construct(
name=odoo_rec.name,
url=odoo_rec.url or None,
type=ShopinvaderProductMediaType.from_shopinvader_product_media_type(
odoo_rec.media_type_id
)
if odoo_rec.media_type_id
else None,
)


class ShopinvaderVariant(BaseShopinvaderVariant, extends=True):
media: list[ShopinvaderProductMedia] = []

@classmethod
def from_shopinvader_variant(cls, odoo_rec):
obj = super().from_shopinvader_variant(odoo_rec)
obj.media = [
ShopinvaderProductMedia.from_shopinvader_product_media(media)
for media in odoo_rec.variant_media_ids
]
return obj

0 comments on commit a1999b5

Please sign in to comment.