[IMP] website_sale(_product_configurator): disable quantity everywhere.
Purpose of the commit is too make the customize option "Select Quantity" works everywhere. When we disable it, it's only disabled from the product page. it's still active on the cart and on the product config modal. So if the user decide to disable the "Select Quantity", disable it everywhere (cart, product config modal, product itself) Task-2008472 closes odoo/odoo#37951 Closes: #37951 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
committed by
Jeremy Kersten
parent
75df756751
commit
4f508676c2
@@ -6,6 +6,22 @@
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<template id="product_quantity_config">
|
||||
<div class="css_quantity input-group">
|
||||
<div class="input-group-prepend">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" data-min="1" name="add_qty" t-att-value="add_qty or 1"/>
|
||||
<div class="input-group-append">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- backend -->
|
||||
<template id="configure" name="Configure">
|
||||
<div class="js_product main_product">
|
||||
@@ -37,19 +53,9 @@
|
||||
"display_currency": (pricelist or product).currency_id
|
||||
}'/>
|
||||
</h2>
|
||||
<div class="css_quantity input-group" t-if="product.visible_qty_configurator">
|
||||
<div class="input-group-prepend">
|
||||
<button t-attf-href="#" class="btn btn-primary js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" data-min="1" name="add_qty" t-att-value="add_qty or 1"/>
|
||||
<div class="input-group-append">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<t t-if="product.visible_qty_configurator">
|
||||
<t t-call="sale_product_configurator.product_quantity_config" />
|
||||
</t>
|
||||
<p class="css_not_available_msg alert alert-warning">This combination does not exist.</p>
|
||||
</div>
|
||||
<div class="col-lg-1 d-inline-block"></div>
|
||||
@@ -72,10 +78,10 @@
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="td-img">Product</th>
|
||||
<th></th>
|
||||
<th class="text-center td-qty">Quantity</th>
|
||||
<th class="text-center td-price">Price</th>
|
||||
<th class="td-img"><span class='label'>Product</span></th>
|
||||
<th><span class='label'></span></th>
|
||||
<th class="text-center td-qty"><span class='label'>Quantity</span></th>
|
||||
<th class="text-center td-price"><span class='label'>Price</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -98,19 +104,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center td-qty">
|
||||
<div class="css_quantity input-group">
|
||||
<div class="input-group-prepend">
|
||||
<button t-attf-href="#" class="btn btn-primary js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" data-min="1" name="add_qty" t-att-value="add_qty or 1"/>
|
||||
<div class="input-group-append">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<t t-call='sale_product_configurator.product_quantity_config' />
|
||||
</td>
|
||||
<td class="text-center td-price" name="price">
|
||||
<ul class="d-none js_add_cart_variants" t-att-data-attribute_exclusions="{'exclusions: []'}"></ul>
|
||||
@@ -178,19 +172,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center td-qty d-none">
|
||||
<div class="css_quantity input-group">
|
||||
<div class="input-group-prepend">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" data-min="1" name="add_qty" t-att-value="add_qty or 1"/>
|
||||
<div class="input-group-append">
|
||||
<button t-attf-href="#" class="btn btn-primary float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<t t-call='sale_product_configurator.product_quantity_config' />
|
||||
</td>
|
||||
<td class="text-center td-price">
|
||||
<div t-attf-class="text-danger oe_default_price oe_optional oe_striked_price {{'' if combination_info['has_discounted_price'] else 'd-none'}}"
|
||||
|
||||
@@ -982,7 +982,12 @@
|
||||
<tr>
|
||||
<th class="td-img">Product</th>
|
||||
<th></th>
|
||||
<th class="text-center td-qty">Quantity</th>
|
||||
<th class="text-center td-qty">
|
||||
<t t-set="show_qty" t-value="is_view_active('website_sale.product_quantity')"/>
|
||||
<t t-if="show_qty">
|
||||
Quantity
|
||||
</t>
|
||||
</th>
|
||||
<th class="text-center td-price">Price</th>
|
||||
<th class="text-center td-action"></th>
|
||||
</tr>
|
||||
@@ -1012,18 +1017,23 @@
|
||||
</td>
|
||||
<td class="text-center td-qty">
|
||||
<div class="css_quantity input-group mx-auto">
|
||||
<t t-if="not line._is_not_sellable_line()">
|
||||
<div class="input-group-prepend">
|
||||
<a t-attf-href="#" class="btn btn-link js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</a>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" t-att-data-line-id="line.id" t-att-data-product-id="line.product_id.id" t-att-value="int(line.product_uom_qty) == line.product_uom_qty and int(line.product_uom_qty) or line.product_uom_qty" />
|
||||
<div class="input-group-append">
|
||||
<a t-attf-href="#" class="btn btn-link float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
<t t-if="not line._is_not_sellable_line()">
|
||||
<t t-if="show_qty">
|
||||
<div class="input-group-prepend">
|
||||
<a t-attf-href="#" class="btn btn-link js_add_cart_json d-none d-md-inline-block" aria-label="Remove one" title="Remove one">
|
||||
<i class="fa fa-minus"></i>
|
||||
</a>
|
||||
</div>
|
||||
<input type="text" class="js_quantity form-control quantity" t-att-data-line-id="line.id" t-att-data-product-id="line.product_id.id" t-att-value="int(line.product_uom_qty) == line.product_uom_qty and int(line.product_uom_qty) or line.product_uom_qty" />
|
||||
<div class="input-group-append">
|
||||
<a t-attf-href="#" class="btn btn-link float_left js_add_cart_json d-none d-md-inline-block" aria-label="Add one" title="Add one">
|
||||
<i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<input type="hidden" class="js_quantity form-control quantity" t-att-data-line-id="line.id" t-att-data-product-id="line.product_id.id" t-att-value="int(line.product_uom_qty) == line.product_uom_qty and int(line.product_uom_qty) or line.product_uom_qty" />
|
||||
</t>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<span class="text-muted w-100" t-esc="int(line.product_uom_qty)"/>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
'auto_install': True,
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/website_sale_product_configurator_templates.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/demo.xml',
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="configure_optional_products_website" inherit_id="sale_product_configurator.configure_optional_products">
|
||||
<xpath expr="//th[hasclass('td-qty')]/span[hasclass('label')]" position="attributes">
|
||||
<attribute name='t-if'>not request.is_frontend or (request.is_frontend and is_view_active('website_sale.product_quantity'))</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
<template id="product_quantity_config_website" inherit_id="sale_product_configurator.product_quantity_config" priority="18">
|
||||
<xpath expr="//div[hasclass('css_quantity')]" position="attributes">
|
||||
<attribute name='t-if'>not request.is_frontend or (request.is_frontend and is_view_active('website_sale.product_quantity'))</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('css_quantity')]" position="after">
|
||||
<input t-else="" type="hidden" class="d-none js_quantity form-control quantity" name="add_qty" t-att-value="add_qty or 1"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="website_sale_stock_modal" inherit_id="sale_product_configurator.configure_optional_products" name="Stocks Modal">
|
||||
<template id="website_sale_stock_modal" inherit_id="sale_product_configurator.product_quantity_config" name="Stocks Modal">
|
||||
<xpath expr="//input[@type='text'][hasclass('quantity')]" position="attributes">
|
||||
<attribute name='t-att-data-max'>max(product.sudo().virtual_available - product.cart_qty, 1) if handle_stock and product.type == "product" and product.inventory_availability in ["always", "threshold"] else None</attribute>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user