[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,29 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.disable.cart</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//block[@id='website_info_settings']" position="after">
<h2>Disabled Cart</h2>
<div class="row mt16 o_settings_container" id="disable_cart_settings">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<label for="disabled_cart_redirect_url" string="Cart Redirect URL"/>
<div class="text-muted">
Internal path visitors land on when they reach a standard cart URL
</div>
<div class="content-group">
<div class="mt16">
<field name="disabled_cart_redirect_url" class="oe_inline" placeholder="/shop"/>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- ==========================================
DISABLE STANDARD WEBSITE_SALE CART
Convert /shop into 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>
<template id="hide_cart_in_header_sales_two" inherit_id="website.template_header_sales_two" name="Hide Cart Link in Header Sales Two">
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
</template>
<template id="hide_cart_in_header_sales_three" inherit_id="website.template_header_sales_three" name="Hide Cart Link in Header Sales Three">
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
</template>
<template id="hide_cart_in_header_sales_four" inherit_id="website.template_header_sales_four" name="Hide Cart Link in Header Sales Four">
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
</template>
<template id="hide_cart_in_header_boxed" inherit_id="website.template_header_boxed" name="Hide Cart Link in Header Boxed">
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="replace"/>
</template>
<template id="hide_cart_in_header_sidebar" inherit_id="website.template_header_sidebar" name="Hide Cart Link in Header Sidebar">
<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>