[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:
parent
73660ee226
commit
f2194c5367
28 changed files with 733 additions and 91 deletions
|
|
@ -1,5 +1,24 @@
|
|||
# Changelog - Website Sale Aplicoop
|
||||
|
||||
## [18.0.1.12.0] - 2026-08-06
|
||||
|
||||
### Removed
|
||||
|
||||
- **Standard cart restriction extracted to `website_sale_disable_cart`**: the cart
|
||||
UI removal (header cart link, add-to-cart buttons) and the `/shop/cart*` route
|
||||
redirects no longer live in this module, so installing Aplicoop leaves the
|
||||
standard `website_sale` shop untouched. Sites that want the previous behaviour
|
||||
must install `website_sale_disable_cart` and set its *Cart Redirect URL* to
|
||||
`/eskaera`. The new module also fixes the route paths (Odoo 18 uses
|
||||
`/shop/cart/quantity`, not `/shop/cart_quantity`), covers the 5 header styles
|
||||
that were missing (boxed, sidebar, sales two/three/four — the header cart link
|
||||
was still visible on those) and overrides the standard endpoints instead of
|
||||
registering duplicate ones.
|
||||
Upgrade order matters: update this module **first** (so its old templates are
|
||||
dropped) and install `website_sale_disable_cart` in a **second** Odoo run —
|
||||
both sets of templates use the same XPaths and obsolete records are only
|
||||
cleaned up at the end of a run, so a single combined run fails.
|
||||
|
||||
## [18.0.1.11.0] - 2026-07-15
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -142,48 +142,22 @@ This module was inspired by the original **Aplicoop** project:
|
|||
|
||||
The original Aplicoop project served as a pioneering solution for collaborative consumption group orders, and this module brings its functionality to the modern Odoo platform.
|
||||
|
||||
Notes - Shop behaves as a simple catalog
|
||||
=========================================
|
||||
Notes - Standard shop and cart
|
||||
==============================
|
||||
|
||||
Starting with the recent update, this module converts the default Odoo
|
||||
``/shop`` storefront into a simple product catalog (no standard ``website_sale``
|
||||
shopping cart). The change is intentional for sites that use the Aplicoop
|
||||
"eskaera" flow as the single shopping experience.
|
||||
This module adds the "eskaera" group order flow (``/eskaera``); it no longer
|
||||
touches the standard ``website_sale`` storefront. The default ``/shop`` and its
|
||||
shopping cart keep working as usual after installing it.
|
||||
|
||||
What the module does
|
||||
---------------------
|
||||
|
||||
- Hides the standard header cart link and badge.
|
||||
- Removes the "Add to cart" quick-add area from product listings.
|
||||
- Redirects standard cart endpoints to the group-order flow (``/eskaera``):
|
||||
``/shop/cart``, ``/shop/cart/update``, ``/shop/cart/update_json``, ``/shop/cart_quantity``.
|
||||
|
||||
Files involved
|
||||
--------------
|
||||
|
||||
- ``views/website_sale_disable_cart.xml`` — templates that hide/remove cart UI
|
||||
- ``controllers/website_sale.py`` — routes that redirect cart endpoints to ``/eskaera``
|
||||
- ``__manifest__.py`` — includes the new view file
|
||||
|
||||
How to apply or revert
|
||||
-----------------------
|
||||
|
||||
To apply the change (already applied when the module is installed/updated):
|
||||
Sites that want the standard cart disabled — so that the group order flow is
|
||||
the single shopping experience — should additionally install
|
||||
``website_sale_disable_cart``, which hides the cart UI and redirects the
|
||||
standard cart endpoints to a configurable URL. That behaviour used to live in
|
||||
this module (up to 18.0.1.11.0) and was extracted in 18.0.1.12.0.
|
||||
|
||||
::
|
||||
|
||||
docker-compose run --rm odoo odoo -d odoo -u website_sale_aplicoop --stop-after-init
|
||||
docker-compose up -d
|
||||
docker-compose run --rm odoo odoo -d odoo -i website_sale_disable_cart --stop-after-init
|
||||
|
||||
To revert back to the standard ``website_sale`` behaviour:
|
||||
|
||||
1. Remove ``views/website_sale_disable_cart.xml`` from the ``data`` section in
|
||||
``__manifest__.py``.
|
||||
2. Update the module:
|
||||
|
||||
::
|
||||
|
||||
docker-compose run --rm odoo odoo -d odoo -u website_sale_aplicoop --stop-after-init
|
||||
|
||||
Note: Reverting may expose standard cart UI and routes; ensure your site
|
||||
content and workflows are adapted accordingly.
|
||||
Then set *Website > Configuration > Settings > Disabled Cart > Cart Redirect
|
||||
URL* to ``/eskaera``.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ Sistema de pedidos colaborativos para grupos de consumo. Reemplaza el legacy Apl
|
|||
## Resumen de funcionalidades
|
||||
|
||||
- Gestión completa de órdenes de grupo (draft → confirmed → collected → invoiced → completed)
|
||||
- Carrito separado por grupo de consumo; tienda estándar de `website_sale` deshabilitada
|
||||
- Carrito separado por grupo de consumo (la tienda estándar de `website_sale` se
|
||||
puede deshabilitar aparte con `website_sale_disable_cart`)
|
||||
- Control de catálogo por listas de inclusión (proveedores, categorías, productos) y exclusión (blacklists)
|
||||
- Cron diario de auto-confirmación + creación automática de lotes de picking
|
||||
- Paginación de productos (lazy loading) para cargas rápidas
|
||||
|
|
@ -86,7 +87,9 @@ Todos los endpoints viven bajo `/eskaera/`:
|
|||
| `POST /eskaera/<order_id>/confirm` | Confirmar carrito (sale.order en draft) |
|
||||
| `POST /eskaera/clear-cart` | Limpiar carrito actual |
|
||||
|
||||
Las rutas `/cart` y `/shop` de `website_sale` están redirigidas a `/eskaera`.
|
||||
Las rutas estándar de `website_sale` (`/shop` y su carrito) no se tocan desde
|
||||
este módulo. Para desactivar el carrito estándar y redirigirlo a `/eskaera`,
|
||||
instala `website_sale_disable_cart` y configura la URL de redirección.
|
||||
|
||||
**Seguridad portal:** los usuarios solo ven órdenes de su `consumer_group_id`. La regla `rule_group_order_company_read` incluye guardia `user.share`.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{ # noqa: B018
|
||||
"name": "Website Sale - Aplicoop",
|
||||
"version": "18.0.1.11.0",
|
||||
"version": "18.0.1.12.0",
|
||||
"category": "Website/Sale",
|
||||
"summary": "Modern replacement of legacy Aplicoop - Collaborative consumption group orders",
|
||||
"author": "Odoo Community Association (OCA), Criptomart",
|
||||
|
|
@ -39,7 +39,6 @@
|
|||
"views/res_partner_views.xml",
|
||||
"views/res_config_settings_views.xml",
|
||||
"views/website_templates.xml",
|
||||
"views/website_sale_disable_cart.xml",
|
||||
"views/product_template_views.xml",
|
||||
"views/sale_order_views.xml",
|
||||
"views/stock_picking_views.xml",
|
||||
|
|
|
|||
|
|
@ -2457,50 +2457,3 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
"empty_cart": "Your cart is empty",
|
||||
"added_to_cart": "added to cart",
|
||||
}
|
||||
|
||||
# ================================================================
|
||||
# CART REDIRECT METHODS - Redirect /shop/cart routes to /eskaera
|
||||
# ================================================================
|
||||
|
||||
@http.route(["/shop/cart"], type="http", auth="public", website=True)
|
||||
def cart_redirect(self, access_token=None, revive="", **post):
|
||||
"""Redirect /shop/cart to /eskaera (no standard cart)."""
|
||||
_logger.info("🛒 Redirecting /shop/cart → /eskaera")
|
||||
return http.redirect_with_hash("/eskaera")
|
||||
|
||||
@http.route(
|
||||
["/shop/cart/update"],
|
||||
type="http",
|
||||
auth="public",
|
||||
website=True,
|
||||
methods=["POST"],
|
||||
)
|
||||
def cart_update_redirect(self, **post):
|
||||
"""Redirect /shop/cart/update to /eskaera (no standard cart)."""
|
||||
_logger.info("🛒 Redirecting /shop/cart/update → /eskaera")
|
||||
return http.redirect_with_hash("/eskaera")
|
||||
|
||||
@http.route(
|
||||
["/shop/cart/update_json"],
|
||||
type="http",
|
||||
auth="public",
|
||||
website=True,
|
||||
methods=["POST"],
|
||||
csrf=False,
|
||||
)
|
||||
def cart_update_json_redirect(self, **post):
|
||||
"""Redirect /shop/cart/update_json to /eskaera (no standard cart)."""
|
||||
_logger.info("🛒 Redirecting /shop/cart/update_json → /eskaera")
|
||||
return http.redirect_with_hash("/eskaera")
|
||||
|
||||
@http.route(
|
||||
["/shop/cart_quantity"],
|
||||
type="http",
|
||||
auth="public",
|
||||
website=True,
|
||||
methods=["GET"],
|
||||
)
|
||||
def cart_quantity_redirect(self):
|
||||
"""Redirect /shop/cart_quantity to /eskaera (no standard cart)."""
|
||||
_logger.info("🛒 Redirecting /shop/cart_quantity → /eskaera")
|
||||
return http.redirect_with_hash("/eskaera")
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- ==========================================
|
||||
DISABLE STANDARD WEBSITE_SALE CART
|
||||
Convert /shop to a simple product catalog
|
||||
========================================== -->
|
||||
|
||||
<!-- Hide the cart link from the header by removing the t-call to website_sale.header_cart_link
|
||||
from the various header templates (more robust than targeting the cart template internals) -->
|
||||
<template id="hide_cart_in_header_default" inherit_id="website.template_header_default" name="Hide Cart Link in Header Default">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_mobile" inherit_id="website.template_header_mobile" name="Hide Cart Link in Header Mobile">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_hamburger" inherit_id="website.template_header_hamburger" name="Hide Cart Link in Header Hamburger">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_stretch" inherit_id="website.template_header_stretch" name="Hide Cart Link in Header Stretch">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_vertical" inherit_id="website.template_header_vertical" name="Hide Cart Link in Header Vertical">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_search" inherit_id="website.template_header_search" name="Hide Cart Link in Header Search">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<template id="hide_cart_in_header_sales_one" inherit_id="website.template_header_sales_one" name="Hide Cart Link in Header Sales One">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
|
||||
</template>
|
||||
|
||||
<!-- Remove "Add to Cart" button from product items in the shop -->
|
||||
<template id="products_item_no_add_to_cart" inherit_id="website_sale.products_item" name="Product Item Without Add to Cart">
|
||||
<!-- Remove the form action that points to /shop/cart/update -->
|
||||
<xpath expr="//form[hasclass('oe_product_cart')]" position="attributes">
|
||||
<attribute name="action">/</attribute>
|
||||
<attribute name="method">get</attribute>
|
||||
</xpath>
|
||||
<!-- Hide the quick add button area completely -->
|
||||
<xpath expr="//div[hasclass('o_wsale_product_btn')]" position="attributes">
|
||||
<attribute name="class" add="d-none" separator=" "/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Hide cart suggestion snippets and related cart features -->
|
||||
<template id="suggested_products_list_hidden" inherit_id="website_sale.suggested_products_list" name="Hide Suggested Products" active="False">
|
||||
<xpath expr="//*[hasclass('js_cart_lines')]" position="attributes">
|
||||
<attribute name="class" add="d-none" separator=" "/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue