-
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.
- Loading branch information
Showing
13 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/shopinvader_api_cart_step/odoo/addons/shopinvader_api_cart_step
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_api_cart_step |
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 @@ | ||
bot pls :) |
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,2 @@ | ||
from . import schemas | ||
from . import helpers |
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,14 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale Cart steps cart API integration", | ||
"summary": """ | ||
Track checkout steps on sale cart. | ||
""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Camptocamp", | ||
"website": "https://github.com/shopinvader/odoo-shopinvader", | ||
"depends": ["sale_cart_step", "shopinvader_api_cart"], | ||
} |
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 cart_helper |
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,20 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# @author: Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class ShopinvaderApiCartRouterHelper(models.AbstractModel): | ||
_inherit = "shopinvader_api_cart.cart_router.helper" | ||
|
||
def _update_prepare_data(self, data): | ||
vals = super()._update_prepare_data(data) | ||
if data.current_step or data.next_step: | ||
vals.update(self._update_prepare_data_step(data)) | ||
return vals | ||
|
||
def _update_prepare_data_step(self, data): | ||
return self.env["sale.order"]._cart_step_update_vals( | ||
current_step=data.current_step, next_step=data.next_step | ||
) |
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 @@ | ||
* Simone Orsi <[email protected]> |
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 @@ | ||
Plugs ``sale_cart_step`` within cart api. |
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 cart |
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,18 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# @author: Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.addons.shopinvader_api_cart.schemas import ( | ||
CartUpdateInput as BaseCartUpdateInput, | ||
) | ||
|
||
|
||
class CartUpdateInput(BaseCartUpdateInput, extends=True): | ||
|
||
current_step: str | None = None | ||
next_step: str | None = None | ||
|
||
def convert_to_sale_write(self): | ||
vals = super().convert_to_sale_write() | ||
# NOTE: is not possible to use `env` to retrive data here | ||
return vals |
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 test_api_cart_step |
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,48 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# @author: Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import json | ||
|
||
from fastapi import status | ||
from requests import Response | ||
|
||
from odoo.addons.shopinvader_api_cart.routers.cart import cart_router | ||
from odoo.addons.shopinvader_api_cart.tests.common import CommonSaleCart | ||
|
||
|
||
class TestSaleCart(CommonSaleCart): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestSaleCart, cls).setUpClass() | ||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) | ||
cls.address_step = cls.env.ref("sale_cart_step.cart_step_address") | ||
cls.checkout_step = cls.env.ref("sale_cart_step.cart_step_checkout") | ||
cls.last_step = cls.env.ref("sale_cart_step.cart_step_last") | ||
|
||
def test_update(self): | ||
so = self.env["sale.order"]._create_empty_cart( | ||
self.default_fastapi_authenticated_partner.id | ||
) | ||
data = { | ||
"current_step": self.address_step.code, | ||
"next_step": self.checkout_step.code, | ||
} | ||
with self._create_test_client(router=cart_router) as test_client: | ||
response: Response = test_client.post( | ||
f"/{so.uuid}/update", content=json.dumps(data) | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertIn(self.address_step, so.cart_step_done_ids) | ||
self.assertEqual(so.cart_step_id, self.checkout_step) | ||
data = { | ||
"current_step": self.checkout_step.code, | ||
"next_step": self.last_step.code, | ||
} | ||
with self._create_test_client(router=cart_router) as test_client: | ||
response: Response = test_client.post( | ||
f"/{so.uuid}/update", content=json.dumps(data) | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertIn(self.checkout_step, so.cart_step_done_ids) | ||
self.assertEqual(so.cart_step_id, self.last_step) |