[ADD] website_sale_disable_cart: extract cart restriction from website_sale_aplicoop

The "shop as a read-only catalog" behaviour lived inside website_sale_aplicoop,
so every site that wanted the eskaera flow also lost the standard cart. It now
ships as its own installable addon, with the redirect target configurable
instead of hardcoded to /eskaera.

- website_sale_disable_cart: hides the cart UI (12 header styles + the product
  card quick-add) and overrides the standard cart endpoints. Redirect URL is
  configurable in Website settings (default /shop); only site-internal paths are
  accepted, so a misconfigured value cannot turn the shop into an open redirect
  nor loop back into a disabled route.
- Fixes carried over from the original code: /shop/cart/quantity is the Odoo 18
  path (it was /shop/cart_quantity, which never matched), the boxed, sidebar and
  sales two/three/four headers were not covered (the cart link stayed visible on
  them), and the routes now override the standard methods instead of registering
  duplicate ones.
- website_sale_aplicoop 18.0.1.12.0: drops the view file and the four redirect
  routes; installing it no longer touches the standard shop.

Upgrade order matters: update website_sale_aplicoop first, then install
website_sale_disable_cart in a second Odoo run — both use the same XPaths and
obsolete records are only cleaned up at the end of a run.

Tests: 8/8 in website_sale_disable_cart, aplicoop unaffected (its 2 failures
predate this change). Verified live on a DB clone: /shop/cart returns 303 to the
configured URL and no cart markup remains on /shop.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
GitHub Copilot 2026-08-06 11:34:59 +02:00
parent 73660ee226
commit f2194c5367
28 changed files with 733 additions and 91 deletions

View file

@ -0,0 +1,15 @@
Go to *Website > Configuration > Settings > Disabled Cart* and set
**Cart Redirect URL**: the internal path visitors land on when they reach a
standard cart URL.
* Default: ``/shop``.
* It is stored in the system parameter
``website_sale_disable_cart.redirect_url``.
* Only site-internal paths are accepted. Absolute URLs (``https://...``) and
protocol relative URLs (``//host/path``) are ignored — otherwise the shop
could be used as an open redirect — as is any path under ``/shop/cart``,
which would loop back into a disabled route. In those cases ``/shop`` is
used and a warning is logged.
Example: on a site running ``website_sale_aplicoop``, set it to ``/eskaera`` so
that every standard cart URL lands on the group order flow.

View file

@ -0,0 +1,6 @@
* `Criptomart <https://criptomart.net>`_:
* Development and maintenance
Extracted from ``website_sale_aplicoop``, where this behaviour was originally
implemented.

View file

@ -0,0 +1,9 @@
**Authors:**
* Criptomart
**Other credits:**
This module extracts the "shop without cart" behaviour that was originally
implemented inside ``website_sale_aplicoop``, so that it can be installed (and
configured) independently of the group order flow.

View file

@ -0,0 +1,25 @@
This module turns the standard Odoo eCommerce shop into a **read-only product
catalog**: visitors can browse, search and open product pages, but the standard
``website_sale`` shopping cart is not reachable any more.
It is meant for sites where the actual ordering happens somewhere else — for
example the group order flow of ``website_sale_aplicoop`` (``/eskaera``), a
quotation request form, or an offline/phone process — while the public shop is
still useful as a catalog.
What it does:
* Hides the cart link and badge from all 12 standard website header styles
(default, mobile, hamburger, stretch, vertical, search, boxed, sidebar and
sales one to four).
* Removes the "Add to cart" quick-add area from the product listing cards.
* Neutralizes the standard cart endpoints:
* ``/shop/cart`` and ``/shop/cart/update`` redirect to a configurable URL.
* ``/shop/cart/update_json`` returns an empty payload (no cart is written).
* ``/shop/cart/quantity`` always returns ``0``.
* ``/shop/cart/clear`` does nothing.
The redirect target is configurable, so the module stays generic: point it to
``/shop`` (default) to keep visitors in the catalog, or to whatever route
implements the real ordering flow of your site.

View file

@ -0,0 +1,13 @@
Install it like any other addon::
docker-compose run --rm odoo odoo -d odoo -i website_sale_disable_cart --stop-after-init
docker-compose up -d
**Upgrading from website_sale_aplicoop <= 18.0.1.11.0**: that module used to
carry these templates itself, under the same XPaths. Update it first so its old
views are dropped, and only then install this module — doing both in a single
Odoo run fails, because obsolete records are only cleaned up at the very end of
the run and both sets of templates would collide::
docker-compose run --rm odoo odoo -d odoo -u website_sale_aplicoop --stop-after-init
docker-compose run --rm odoo odoo -d odoo -i website_sale_disable_cart --stop-after-init

View file

@ -0,0 +1,10 @@
There is nothing to do at runtime: once installed, the cart is disabled site
wide.
To go back to the standard behaviour, simply uninstall the module. All the
template modifications are removed with it and the ``website_sale`` cart works
again as usual.
Note that this module only disables the **cart**. Checkout and payment routes
are left untouched; with an empty cart they redirect back to the cart route,
and therefore to the configured URL.