-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] shopinvader_api_payment_cart: add /current/payable route
- Loading branch information
1 parent
0b87fca
commit 84e3323
Showing
1 changed file
with
5 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# @author Stéphane Bidoul <[email protected]> | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from typing import Annotated | ||
from uuid import UUID | ||
|
||
from fastapi import Depends, HTTPException | ||
|
||
|
@@ -18,18 +19,19 @@ | |
from odoo.addons.shopinvader_api_payment.schemas import PaymentData | ||
|
||
|
||
@cart_router.get("/payable") | ||
@cart_router.get("/{uuid}/payable") | ||
@cart_router.get("/current/payable") | ||
def init( | ||
env: Annotated[api.Environment, Depends(authenticated_partner_env)], | ||
partner: Annotated["ResPartner", Depends(authenticated_partner)], | ||
uuid: str | None = None, | ||
uuid: UUID | None = None, | ||
) -> PaymentData | None: | ||
"""Prepare payment data for the current cart. | ||
This route is authenticated, so we can verify the cart | ||
is accessible by the authenticated partner. | ||
""" | ||
cart = env["sale.order"]._find_open_cart(partner.id, uuid) | ||
cart = env["sale.order"]._find_open_cart(partner.id, str(uuid) if uuid else None) | ||
if not cart: | ||
raise HTTPException(status_code=404) | ||
sale_order = env["sale.order"].browse(cart.id) | ||
|