Skip to content

Commit

Permalink
[IMP] Use StrictExtendableBaseModel in schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
marielejeune committed Jul 31, 2023
1 parent 83abd89 commit 606378e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# generated from manifests external_dependencies
extendable-pydantic>=1.0.0
extendable-pydantic>=1.1.0
extendable_pydantic>=1.0.0
fastapi
openupgradelib
pydantic>=2.0.0
2 changes: 1 addition & 1 deletion shopinvader_api_cart/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"python": [
"fastapi",
"pydantic>=2.0.0",
"extendable-pydantic>=1.0.0",
"extendable-pydantic>=1.1.0",
]
},
"pre_init_hook": "pre_init_hook",
Expand Down
7 changes: 4 additions & 3 deletions shopinvader_api_cart/schemas/amount.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel, Field
from pydantic import Field

from odoo.tools.float_utils import float_round

from odoo.addons.extendable_fastapi import StrictExtendableBaseModel

class SaleAmount(BaseModel, metaclass=ExtendableModelMeta):

class SaleAmount(StrictExtendableBaseModel):
tax: float = Field(description="Tax amount")
untaxed: float = Field(description="Amount untaxed")
total: float = Field(description="Total amount")
Expand Down
10 changes: 4 additions & 6 deletions shopinvader_api_cart/schemas/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from datetime import datetime
from typing import List

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel

from odoo.addons.extendable_fastapi import StrictExtendableBaseModel
from odoo.addons.shopinvader_schema_address.schemas import (
BillingAddress,
ShippingAddress,
Expand All @@ -16,17 +14,17 @@
from .sale_order_line import SaleOrderLine


class CartTransaction(BaseModel, metaclass=ExtendableModelMeta):
class CartTransaction(StrictExtendableBaseModel):
uuid: str | None = None
qty: float
product_id: int


class CartSyncInput(BaseModel, metaclass=ExtendableModelMeta):
class CartSyncInput(StrictExtendableBaseModel):
transactions: List[CartTransaction]


class CartResponse(BaseModel, metaclass=ExtendableModelMeta):
class CartResponse(StrictExtendableBaseModel):
uuid: str | None = None
id: int
state: str
Expand Down
5 changes: 2 additions & 3 deletions shopinvader_api_cart/schemas/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from extendable_pydantic import ExtendableModelMeta
from pydantic import BaseModel
from odoo.addons.extendable_fastapi import StrictExtendableBaseModel

from .amount import SaleLineAmount


class SaleOrderLine(BaseModel, metaclass=ExtendableModelMeta):
class SaleOrderLine(StrictExtendableBaseModel):
id: int
product_id: int
name: str
Expand Down
7 changes: 1 addition & 6 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ vcrpy-unittest
unittest2 # For shopinvader test_controller, which inherits component
odoo-test-helper
httpx # For FastAPI tests
odoo-addon-shopinvader-schema-address @ git+https://github.com/shopinvader/odoo-shopinvader@refs/pull/1361/head#subdirectory=setup/shopinvader_schema_address
odoo-addon-shopinvader-api-address @ git+https://github.com/shopinvader/odoo-shopinvader@refs/pull/1361/head#subdirectory=setup/shopinvader_api_address
odoo-addon-shopinvader-address @ git+https://github.com/shopinvader/odoo-shopinvader@refs/pull/1361/head#subdirectory=setup/shopinvader_address
odoo-addon-extendable @ git+https://github.com/oca/rest-framework@refs/pull/348/head#subdirectory=setup/extendable
odoo-addon-fastapi @ git+https://github.com/oca/rest-framework@refs/pull/348/head#subdirectory=setup/fastapi
odoo-addon-extendable-fastapi @ git+https://github.com/oca/rest-framework@refs/pull/348/head#subdirectory=setup/extendable_fastapi
odoo-addon-extendable-fastapi @ git+https://github.com/oca/rest-framework@refs/pull/364/head#subdirectory=setup/extendable_fastapi

0 comments on commit 606378e

Please sign in to comment.