From 120cab00d3691d59de5a4fe4e20954855603a1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Mon, 16 Oct 2023 23:44:06 +0200 Subject: [PATCH] shopinvader_schema_sale: clean schema naming --- shopinvader_schema_sale/readme/DESCRIPTION.rst | 2 +- shopinvader_schema_sale/schemas/__init__.py | 2 +- .../schemas/{shipping.py => delivery.py} | 8 ++++---- shopinvader_schema_sale/schemas/invoicing.py | 6 +++--- shopinvader_schema_sale/schemas/sale_order.py | 8 +++----- 5 files changed, 12 insertions(+), 14 deletions(-) rename shopinvader_schema_sale/schemas/{shipping.py => delivery.py} (61%) diff --git a/shopinvader_schema_sale/readme/DESCRIPTION.rst b/shopinvader_schema_sale/readme/DESCRIPTION.rst index 90ee135c67..e3a3e59f6f 100644 --- a/shopinvader_schema_sale/readme/DESCRIPTION.rst +++ b/shopinvader_schema_sale/readme/DESCRIPTION.rst @@ -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. diff --git a/shopinvader_schema_sale/schemas/__init__.py b/shopinvader_schema_sale/schemas/__init__.py index 21c4e6141f..3b5489193f 100644 --- a/shopinvader_schema_sale/schemas/__init__.py +++ b/shopinvader_schema_sale/schemas/__init__.py @@ -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 diff --git a/shopinvader_schema_sale/schemas/shipping.py b/shopinvader_schema_sale/schemas/delivery.py similarity index 61% rename from shopinvader_schema_sale/schemas/shipping.py rename to shopinvader_schema_sale/schemas/delivery.py index 03f374df0f..ee6e247f3c 100644 --- a/shopinvader_schema_sale/schemas/shipping.py +++ b/shopinvader_schema_sale/schemas/delivery.py @@ -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)) ) diff --git a/shopinvader_schema_sale/schemas/invoicing.py b/shopinvader_schema_sale/schemas/invoicing.py index 10f45ecc0c..85a6fb24de 100644 --- a/shopinvader_schema_sale/schemas/invoicing.py +++ b/shopinvader_schema_sale/schemas/invoicing.py @@ -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)) ) diff --git a/shopinvader_schema_sale/schemas/sale_order.py b/shopinvader_schema_sale/schemas/sale_order.py index beee1655cc..b97e23cecb 100644 --- a/shopinvader_schema_sale/schemas/sale_order.py +++ b/shopinvader_schema_sale/schemas/sale_order.py @@ -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): @@ -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 @@ -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, )