Compare commits
No commits in common. "e2a22c5d71da2b198ab2fdb641c41470965dc1e7" and "66a5e31060008ffee2a2ff39d2c9c60bffaabaec" have entirely different histories.
e2a22c5d71
...
66a5e31060
6 changed files with 3 additions and 45 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 111 KiB |
|
|
@ -1558,11 +1558,7 @@ class AplicoopWebsiteSale(WebsiteSale):
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
cutoff_passed = bool(
|
if group_order.state != "open":
|
||||||
group_order.cutoff_date
|
|
||||||
and group_order.cutoff_date < fields.Date.today()
|
|
||||||
)
|
|
||||||
if group_order.state != "open" or cutoff_passed:
|
|
||||||
return self._build_group_order_unavailable_response(group_order)
|
return self._build_group_order_unavailable_response(group_order)
|
||||||
|
|
||||||
current_user = request.env.user
|
current_user = request.env.user
|
||||||
|
|
|
||||||
|
|
@ -1885,7 +1885,7 @@ msgstr "Guardar Carrito"
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
|
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
|
||||||
msgid "Save as Draft"
|
msgid "Save as Draft"
|
||||||
msgstr "Guardar Carrito"
|
msgstr "Grabar pedido"
|
||||||
|
|
||||||
#. module: website_sale_aplicoop
|
#. module: website_sale_aplicoop
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
|
|
|
||||||
|
|
@ -1882,7 +1882,7 @@ msgstr "Saskia Gorde"
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
|
#: code:addons/website_sale_aplicoop/models/js_translations.py:0
|
||||||
msgid "Save as Draft"
|
msgid "Save as Draft"
|
||||||
msgstr "Sakia gorde"
|
msgstr "Eskaera gorde"
|
||||||
|
|
||||||
#. module: website_sale_aplicoop
|
#. module: website_sale_aplicoop
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,6 @@
|
||||||
console.log("Attempting to auto-load draft order...");
|
console.log("Attempting to auto-load draft order...");
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this._skipDraftAutoLoad) {
|
|
||||||
console.log("Auto-load draft skipped (order closed or cutoff passed)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only auto-load if cart is empty
|
// Only auto-load if cart is empty
|
||||||
var cartItemsCount = Object.keys(this.cart).length;
|
var cartItemsCount = Object.keys(this.cart).length;
|
||||||
if (cartItemsCount > 0) {
|
if (cartItemsCount > 0) {
|
||||||
|
|
@ -511,7 +506,6 @@
|
||||||
shouldClear = true;
|
shouldClear = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self._skipDraftAutoLoad = shouldClear;
|
|
||||||
if (shouldClear) {
|
if (shouldClear) {
|
||||||
console.log(
|
console.log(
|
||||||
"[groupOrderShop] check-status: clearing cart (reason:",
|
"[groupOrderShop] check-status: clearing cart (reason:",
|
||||||
|
|
|
||||||
|
|
@ -102,38 +102,6 @@ class TestGroupOrderStatusEndpoint(TransactionCase):
|
||||||
self.assertEqual(data["state"], "closed")
|
self.assertEqual(data["state"], "closed")
|
||||||
self.assertEqual(data["action"], "clear_cart")
|
self.assertEqual(data["action"], "clear_cart")
|
||||||
|
|
||||||
def test_load_draft_endpoint_rejects_when_cutoff_passed(self):
|
|
||||||
"""/eskaera/load-draft must refuse to load drafts when cutoff_date is in
|
|
||||||
the past, even if the group.order is still in 'open' state.
|
|
||||||
|
|
||||||
Regression: previously the endpoint only checked group_order.state, so
|
|
||||||
when cutoff had passed the previous cycle's draft was returned and
|
|
||||||
repopulated the cart on the next page load.
|
|
||||||
"""
|
|
||||||
# Force cutoff_date into the past. The @api.depends compute always
|
|
||||||
# rolls forward to the next occurrence, so we have to write directly
|
|
||||||
# to the stored field to simulate a stale cycle.
|
|
||||||
past = fields.Date.today() - timedelta(days=1)
|
|
||||||
self.group_order.sudo().write({"cutoff_date": past})
|
|
||||||
# Sanity: state remains open; only cutoff is stale.
|
|
||||||
self.assertEqual(self.group_order.state, "open")
|
|
||||||
self.assertLess(self.group_order.cutoff_date, fields.Date.today())
|
|
||||||
|
|
||||||
payload = {"order_id": self.group_order.id}
|
|
||||||
request_mock = self._build_request_mock(payload)
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"odoo.addons.website_sale_aplicoop.controllers.website_sale.request",
|
|
||||||
request_mock,
|
|
||||||
):
|
|
||||||
response = self.controller.load_draft_cart.__wrapped__(self.controller)
|
|
||||||
|
|
||||||
data = json.loads(response.data.decode("utf-8"))
|
|
||||||
self.assertEqual(response.status, 403)
|
|
||||||
self.assertEqual(data.get("code"), "group_order_not_open")
|
|
||||||
self.assertEqual(data.get("action"), "clear_cart")
|
|
||||||
self.assertNotIn("items", data)
|
|
||||||
|
|
||||||
def test_save_order_endpoint_rejects_closed_group_order(self):
|
def test_save_order_endpoint_rejects_closed_group_order(self):
|
||||||
"""/eskaera/save-order must reject closed group order with clear_cart action."""
|
"""/eskaera/save-order must reject closed group order with clear_cart action."""
|
||||||
self.group_order.action_close()
|
self.group_order.action_close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue