-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] shopinvader_product_media: Migration to 16.0
- Loading branch information
Showing
8 changed files
with
60 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
setup/shopinvader_product_media/odoo/addons/shopinvader_product_media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../shopinvader_product_media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |