[FIX] website_sale_aplicoop: three defects in the group order slug
- create(): slugs were only checked against the database, so records created in the same batch (duplicating several orders from the list view, importing rows sharing a name) collided on group_order_slug_uniq. _generate_unique_slug now also skips the slugs already handed out in the batch. - _redirect_to_slug_url(): `post` is passed as a dict instead of splatted, so a query parameter named `suffix` no longer binds to the keyword argument of the same name (HTTP 500 on /eskaera/<id>/checkout?suffix=x, and a corrupted path on the shop route). - post-migrate: the backfill runs with tracking_disable, `slug` is tracked and the upgrade posted a chatter message on every pre-existing order. Tests for the two reachable cases: batch create and query parameters kept across the legacy redirect. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
23edee6154
commit
157b344d4b
4 changed files with 65 additions and 20 deletions
|
|
@ -718,8 +718,12 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
return "/eskaera"
|
||||
return f"/eskaera/{group_order.slug}{suffix}"
|
||||
|
||||
def _redirect_to_slug_url(self, order_id, suffix="", **post):
|
||||
"""Send a legacy /eskaera/<id> URL to its /eskaera/<slug> equivalent."""
|
||||
def _redirect_to_slug_url(self, order_id, post, suffix=""):
|
||||
"""Send a legacy /eskaera/<id> URL to its /eskaera/<slug> equivalent.
|
||||
|
||||
`post` is passed as a plain dict, not splatted: a query parameter named
|
||||
`suffix` would otherwise land on the keyword argument of the same name.
|
||||
"""
|
||||
group_order = request.env["group.order"].sudo().browse(order_id).exists()
|
||||
url = self._eskaera_url(group_order, suffix=suffix)
|
||||
if post and url != "/eskaera":
|
||||
|
|
@ -729,7 +733,7 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
@http.route(["/eskaera/<int:order_id>"], type="http", auth="user", website=True)
|
||||
def eskaera_shop_legacy(self, order_id, **post):
|
||||
"""Keep the old numeric shop URL working, pointing at the slug one."""
|
||||
return self._redirect_to_slug_url(order_id, **post)
|
||||
return self._redirect_to_slug_url(order_id, post)
|
||||
|
||||
@http.route(
|
||||
["/eskaera/<string:group_order_slug>"],
|
||||
|
|
@ -1296,7 +1300,7 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
)
|
||||
def eskaera_checkout_legacy(self, order_id, **post):
|
||||
"""Keep the old numeric checkout URL working, pointing at the slug one."""
|
||||
return self._redirect_to_slug_url(order_id, suffix="/checkout", **post)
|
||||
return self._redirect_to_slug_url(order_id, post, suffix="/checkout")
|
||||
|
||||
@http.route(
|
||||
["/eskaera/<string:group_order_slug>/checkout"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue