Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website_sale_hide_all_prices/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Usage

To use this module, you need to:

#. Just use the module.
#. Just use the module..

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
Expand Down
4 changes: 2 additions & 2 deletions website_sale_hide_all_prices/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
"name": "Website Sale Hide All Prices",
"category": "website",
"version": "18.0.2.0.0",
"version": "19.0.1.0.0",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
Expand All @@ -37,5 +37,5 @@
"website_sale_hide_all_prices/static/src/components/product_configurator_dialog.js",
]
},
"installable": False,
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/** @odoo-module **/

import { session } from "@web/session";
import { AddToCartNotification } from "@website_sale/js/notification/add_to_cart_notification/add_to_cart_notification";
import { CartNotification } from "@website_sale/js/notification/cart_notification/cart_notification";
import { WarningNotification } from "@website_sale/js/notification/warning_notification/warning_notification";

class MyAddToCartNotification extends AddToCartNotification {
setup(){
super.setup();
this.props['website_hide_all_prices'] = session['website_hide_all_prices']
}
}
import { patch } from "@web/core/utils/patch";
Comment on lines 1 to +3

CartNotification.components = { AddToCartNotification: MyAddToCartNotification , WarningNotification }
patch(AddToCartNotification.prototype, {
get websiteHideAllPrices() {
return !!session.website_hide_all_prices;
},
});
Comment on lines +5 to +9

MyAddToCartNotification.template = 'website_sale_hide_all_prices.MyAddToCartNotification'
AddToCartNotification.template = "website_sale_hide_all_prices.MyAddToCartNotification";
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="website_sale_hide_all_prices.MyAddToCartNotification">
<div class="row g-2 mb-2" t-foreach="props.lines" t-as="line" t-key="line.id">
<div class="col-3">
<img class="img o_image_64_max rounded mb-2 img-fluid"
t-att-src="line.image_url"
t-att-alt="line.name"/>
</div>
<div class="col-6 d-flex flex-column align-items-start">
<span t-out="getProductSummary(line)"/>
<span class="text-muted small"
t-if="line.description"
t-out="line.description"/>
</div>
<div t-if="!props.website_hide_all_prices" class="col-3 d-flex flex-column align-items-end gap-1"
t-out="getFormattedPrice(line)"/>

<t t-name="website_sale_hide_all_prices.MyAddToCartNotification">
<div
class="d-flex flex-column gap-2 mb-2 mt-1"
t-foreach="mainLines"
t-as="line"
t-key="line.id"
>
<t t-call="website_sale_hide_all_prices.cartLine"/>
Comment on lines +5 to +11
</div>
<a role="button" class="w-100 btn btn-primary" href="/shop/cart">
View cart
</a>
</t>

<t t-name="website_sale_hide_all_prices.cartLine">
<div class="d-flex gap-3">
<div class="position-relative">
<div class="o_cart_product_image">
<img
class="img o_image_64_max rounded mb-2 img-fluid"
t-att-src="line.image_url"
t-att-alt="line.name"
/>
</div>
<span
class="o_cart_item_count badge bg-secondary position-absolute top-0 start-100 translate-middle"
t-out="line.quantity"
/>
</div>
<div class="d-flex flex-column align-items-start flex-grow-1">
<span t-out="line.name"/>
<span
t-if="line.combination_name"
class="text-muted small"
t-out="line.combination_name"
/>
<span t-if="line.description" class="text-muted small" t-out="line.description"/>
<span t-out="line.uom_name" class="badge mt-1 bg-light"/>
</div>
<div
t-if="!line.linked_line_id and !websiteHideAllPrices"
class="col-3 d-flex flex-column align-items-end gap-1"
t-out="getFormattedPrice(line)"
/>
</div>
<div
class="d-flex ps-5"
t-foreach="getLinkedLines(line.id)"
t-as="linkedLine"
t-key="linkedLine.id"
>
<t t-call="website_sale_hide_all_prices.cartLine">
<t t-set="line" t-value="linkedLine"/>
</t>
</div>
</t>

</templates>
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/** @odoo-module **/

import { useSubEnv } from "@odoo/owl";
import { ProductConfiguratorDialog } from '@sale/js/product_configurator_dialog/product_configurator_dialog';
import { patch } from '@web/core/utils/patch';
import { ProductConfiguratorDialog } from "@sale/js/product_configurator_dialog/product_configurator_dialog";
import { patch } from "@web/core/utils/patch";
import { session } from "@web/session";
Comment on lines 1 to 4

patch(ProductConfiguratorDialog.prototype, {
setup() {
setup() {
super.setup(...arguments);
this.props['website_hide_all_prices'] = session['website_hide_all_prices']

useSubEnv({
showPrice: !this.props.website_hide_all_prices ?? true,
showPrice: !session.website_hide_all_prices,
});
},
});
Comment on lines 6 to 13
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.website.sale</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
<field name="inherit_id" ref="website_sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//block[@id='sale_product_catalog_settings']" position="inside">
<xpath expr="//setting[@id='hide_add_to_cart_setting']" position="after">
<setting id="website_hide_all_prices" string="Hide all prices in my eCommerce" help="All prices on the eCommerce site will be hidden, but customers will be able to add products to the cart in order to request a quote.">
<field name="website_hide_all_prices"/>
</setting>
Expand Down
70 changes: 46 additions & 24 deletions website_sale_hide_all_prices/views/templates.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,86 @@
<odoo>
<template id="product_price" inherit_id="website_sale.product_price">
<xpath expr="//div[@itemprop='offers']" position="attributes">
<!-- product_price: en v19 el div ya no tiene itemprop='offers', usa name='product_price' -->
<template id="product_price" inherit_id="website_sale.product_price">
<xpath expr="//div[@name='product_price']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
Comment on lines +3 to 6
</template>
<template id="product" inherit_id="website_sale.product">
<xpath expr="//small[@groups='website_sale.group_show_uom_price']" position="attributes">
<attribute name="t-if">combination_info['base_unit_price'] or not website.website_hide_all_prices</attribute>

<!-- product: en v19 el small ya no tiene groups='group_show_uom_price',
se identifica por la clase o_base_unit_price_wrapper dentro del bloque de precio -->
<template id="product" inherit_id="website_sale.product">
<xpath expr="//div[hasclass('o_wsale_product_details_content_section_price')]/small[hasclass('o_base_unit_price_wrapper')]" position="attributes">
<attribute name="t-if">combination_info.get('base_unit_price') and not website.website_hide_all_prices</attribute>
</xpath>
</template>

<!-- products_item: en v19 el precio está en div.product_price (no itemprop='offers') -->
<template id="products_item" inherit_id="website_sale.products_item">
<xpath expr="//div[@itemprop='offers']" position="attributes">
<xpath expr="//div[hasclass('product_price')]" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
</template>

<!-- suggested_products_list: en v19 el precio está en h6[@name='suggested_product_price_container']
(en v18 era div[@name='website_sale_suggested_product_price']) -->
<template id="suggested_products_list" inherit_id="website_sale.suggested_products_list">
<xpath expr="//div[@name='website_sale_suggested_product_price']" position="attributes">
<xpath expr="//h6[@name='suggested_product_price_container']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
</template>

<template id="cart_lines" inherit_id="website_sale.cart_lines">
<xpath expr="//div[@name='website_sale_cart_line_price']" position="attributes">
<!-- cart_lines_price: en v19 el precio fue extraído a template separado 'cart_lines_price'
y el elemento cambió de div a h6 -->
<template id="cart_lines_price" inherit_id="website_sale.cart_lines_price">
<xpath expr="//h6[@name='website_sale_cart_line_price']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
</template>

<template id="total" inherit_id="website_sale.total">
<xpath expr="//div[@id='cart_total']/table" position="attributes">
<attribute name="t-attf-class">#{website.website_hide_all_prices and 'd-none' or ''}</attribute>
<!-- total: en v19 ya no existe div[@id='cart_total']; se oculta el bloque completo via t-if -->
<template id="total" inherit_id="website_sale.total">
<xpath expr="//div[contains(@t-attf-class, 'o_cart_total')]" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices and website_sale_order and website_sale_order.website_order_line</attribute>
</xpath>
</template>
Comment on lines +41 to 45

<!-- delivery_form: //form[@id='o_delivery_form'] sigue existiendo en v19 -->
<template id="delivery_form" inherit_id="website_sale.delivery_form">
<xpath expr="//form[@id='o_delivery_form']" position="attributes">
<xpath expr="//form[@id='o_delivery_form']" position="attributes">
<attribute name="t-attf-class">#{website.website_hide_all_prices and 'd-none' or ''}</attribute>
</xpath>
</template>

<!-- checkout_layout: amount_total_summary está en checkout_layout -->
<template id="checkout_layout" inherit_id="website_sale.checkout_layout">
<xpath expr="//span[@id='amount_total_summary']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
</template>

<!-- cart_summary_content: website_sale_cart_summary_line_price está en este sub-template -->
<template id="cart_summary_content" inherit_id="website_sale.cart_summary_content">
<xpath expr="//td[@name='website_sale_cart_summary_line_price']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
</template>

<template id="navigation_buttons" inherit_id="website_sale.navigation_buttons">
<xpath expr="//a[@name='website_sale_main_button']/t" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
</xpath>
<xpath expr="//a[@name='website_sale_main_button']/t" position="after">
<t t-if="website.website_hide_all_prices">
<span>Request Quotation</span>
</t>
<!-- navigation_buttons: en v19 el <a name="website_sale_main_button"> ya no tiene hijo <t>.
Se mantiene el <a> funcional (mismo href/clases) y solo se reemplaza el label interno. -->
<template id="navigation_buttons" inherit_id="website_sale.navigation_buttons">
<xpath expr="//a[@name='website_sale_main_button']/span[@t-field='next_website_checkout_step.main_button_label']" position="replace">
<t t-if="website.website_hide_all_prices">
<span>Request Quotation</span>
</t>
<t t-else="">
<span t-field="next_website_checkout_step.main_button_label"/>
</t>
</xpath>
</template>

<!-- payment_status: //div[@name='o_payment_status'] sigue existiendo en v19 -->
<template id="payment_status" inherit_id="payment.payment_status">
<xpath expr="//div[@name='o_payment_status']" position="attributes">
<xpath expr="//div[@name='o_payment_status']" position="attributes">
<attribute name="t-attf-class">#{website.website_hide_all_prices and 'd-none' or ''}</attribute>
</xpath>
</template>
Expand All @@ -81,9 +101,11 @@
</t>
</template>

<!-- badge_extra_price: //span[@t-if='price_extra'] sigue existiendo en v19.
Se combina la condición original con la nueva para no perder la lógica de price_extra. -->
<template id="badge_extra_price" inherit_id="website_sale.badge_extra_price">
<xpath expr="//span[@t-if='price_extra']" position="attributes">
<attribute name="t-if">not website.website_hide_all_prices</attribute>
<xpath expr="//span[@t-if='price_extra']" position="attributes">
<attribute name="t-if">price_extra and not website.website_hide_all_prices</attribute>
</xpath>
</template>

Expand Down
Loading