[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
|
|
@ -17,9 +17,13 @@ def migrate(cr, version):
|
|||
if not version:
|
||||
return
|
||||
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
# tracking_disable: `slug` is a tracked field, backfilling it would post a
|
||||
# chatter message and notify the followers of every pre-existing order.
|
||||
env = api.Environment(cr, SUPERUSER_ID, {"tracking_disable": True})
|
||||
orders = env["group.order"].search([("slug", "=", False)], order="id")
|
||||
for order in orders:
|
||||
# One write at a time: the search inside `_generate_unique_slug` flushes
|
||||
# the previous one, so two orders sharing a name get distinct slugs.
|
||||
order.slug = order._generate_unique_slug(order.name)
|
||||
|
||||
if orders:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue