Skip to content

Commit

Permalink
shopinvader_schema_sale: clean schema naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Oct 16, 2023
1 parent b7074c6 commit 6b8db1d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion shopinvader_schema_sale/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This addon adds pydantic schemas that represents Addresses.
It introduces BillingAddress and ShippingAddress as sub classes of Address.
It introduces InvoicingAddress and DeliveryAddress as sub classes of Address.
It has been designed and thought to be used in shopinvader services.
2 changes: 1 addition & 1 deletion shopinvader_schema_sale/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .shipping import ShippingInfo
from .delivery import DeliveryInfo
from .invoicing import InvoicingInfo
from .sale_order_line import SaleOrderLine
from .amount import SaleAmount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@


from odoo.addons.extendable_fastapi import StrictExtendableBaseModel
from odoo.addons.shopinvader_schema_address.schemas import ShippingAddress
from odoo.addons.shopinvader_schema_address.schemas import DeliveryAddress


class ShippingInfo(StrictExtendableBaseModel):
address: ShippingAddress | None = None
class DeliveryInfo(StrictExtendableBaseModel):
address: DeliveryAddress | None = None

@classmethod
def from_sale_order(cls, odoo_rec):
return cls.model_construct(
address=(ShippingAddress.from_res_partner(odoo_rec.partner_shipping_id))
address=(DeliveryAddress.from_res_partner(odoo_rec.partner_shipping_id))
)
6 changes: 3 additions & 3 deletions shopinvader_schema_sale/schemas/invoicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@


from odoo.addons.extendable_fastapi import StrictExtendableBaseModel
from odoo.addons.shopinvader_schema_address.schemas import BillingAddress
from odoo.addons.shopinvader_schema_address.schemas import InvoicingAddress


class InvoicingInfo(StrictExtendableBaseModel):
address: BillingAddress | None = None
address: InvoicingAddress | None = None

@classmethod
def from_sale_order(cls, odoo_rec):
return cls.model_construct(
address=(BillingAddress.from_res_partner(odoo_rec.partner_invoice_id))
address=(InvoicingAddress.from_res_partner(odoo_rec.partner_invoice_id))
)
8 changes: 3 additions & 5 deletions shopinvader_schema_sale/schemas/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from odoo.addons.extendable_fastapi import StrictExtendableBaseModel

from .amount import SaleAmount
from .delivery import DeliveryInfo
from .invoicing import InvoicingInfo
from .sale_order_line import SaleOrderLine
from .shipping import ShippingInfo


class Sale(StrictExtendableBaseModel):
Expand All @@ -22,10 +22,8 @@ class Sale(StrictExtendableBaseModel):
date_commitment: datetime | None = None
lines: List[SaleOrderLine]
amount: SaleAmount | None = None
# TODO discuss about this (should we keep the same schema for this field)
shipping: ShippingInfo | None = None
delivery: DeliveryInfo | None = None
invoicing: InvoicingInfo | None = None
# TODO END
typology: str
note: str | None = None

Expand All @@ -44,7 +42,7 @@ def from_sale_order(cls, odoo_rec):
SaleOrderLine.from_sale_order_line(line) for line in odoo_rec.order_line
],
amount=SaleAmount.from_sale_order(odoo_rec),
shipping=ShippingInfo.from_sale_order(odoo_rec),
delivery=DeliveryInfo.from_sale_order(odoo_rec),
invoicing=InvoicingInfo.from_sale_order(odoo_rec),
note=odoo_rec.note or None,
)

0 comments on commit 6b8db1d

Please sign in to comment.