Merge pull request #17 from bakeupboys/82-16.0-fix_website_decimal_qty

[fix] make max qty work with the website_decimal_qty module
This commit is contained in:
madmooose 2024-09-13 10:04:53 +02:00 committed by GitHub
commit 84cbbdfdf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View file

@ -5,7 +5,7 @@
"website": "https://www.bakeup.org", "website": "https://www.bakeup.org",
"category": "website", "category": "website",
"version": "16.0.1.0.0", "version": "16.0.1.0.0",
"depends": ["website_sale", "nfu_sale_order_batch_packaging"], "depends": ["website_sale", "nfu_sale_order_batch_packaging", "website_decimal_quantity"],
"data": ["views/product_template_views.xml", "views/templates.xml"], "data": ["views/product_template_views.xml", "views/templates.xml"],
"assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]}, "assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]},
"license": "LGPL-3", "license": "LGPL-3",

View file

@ -15,8 +15,8 @@ odoo.define("nfu_ecommerce.website_max_qty", function (require) {
productIDs.push($(elem).find("span[data-product-id]").data("product-id")); productIDs.push($(elem).find("span[data-product-id]").data("product-id"));
}); });
$input.data("update_change", true); $input.data("update_change", true);
var max_qty = parseInt($input.closest("tr").find('input[name="max-qty"]').val(), 10); var max_qty = parseFloat($input.closest("tr").find('input[name="max-qty"]').val(), 10);
var set_qty = parseInt($input.closest("tr").find('input[name!="max-qty"]').val(), 10); var set_qty = parseFloat($input.closest("tr").find('input[name!="max-qty"]').val(), 10);
if (max_qty < set_qty) { if (max_qty < set_qty) {
max_qty = set_qty; max_qty = set_qty;
} }
@ -30,7 +30,7 @@ odoo.define("nfu_ecommerce.website_max_qty", function (require) {
}, },
}).then(function (data) { }).then(function (data) {
$input.data("update_change", false); $input.data("update_change", false);
var check_value = parseInt($input.val() || 0, 10); var check_value = parseFloat($input.val() || 0, 10);
if (isNaN(check_value)) { if (isNaN(check_value)) {
check_value = 1; check_value = 1;
} }
@ -44,8 +44,8 @@ odoo.define("nfu_ecommerce.website_max_qty", function (require) {
} }
$input.val(data.quantity); $input.val(data.quantity);
$(".js_quantity[data-line-id=" + line_id + "]") $(".js_quantity[data-line-id=" + line_id + "]")
.val(data.quantity) .val(data.quantity)
.text(data.quantity); .text(data.quantity);
wSaleUtils.updateCartNavBar(data); wSaleUtils.updateCartNavBar(data);
wSaleUtils.showWarning(data.warning); wSaleUtils.showWarning(data.warning);

View file

@ -37,8 +37,8 @@
class="js_quantity form-control quantity" class="js_quantity form-control quantity"
t-att-data-line-id="line.id" t-att-data-line-id="line.id"
t-att-data-product-id="line.product_id.id" t-att-data-product-id="line.product_id.id"
t-att-value="line.product_uom_max_qty and int(line.product_uom_max_qty) or int(line.product_uom_qty)" t-att-value="line.product_uom_max_qty and line.product_uom_max_qty or line.product_uom_qty"
t-att-data-min="int(line.product_uom_qty)" t-att-data-min="line.product_uom_qty"
/> />
<t t-if="line._get_shop_warning(clear=False)"> <t t-if="line._get_shop_warning(clear=False)">
<a t-attf-href="#" class="btn btn-link"> <a t-attf-href="#" class="btn btn-link">
@ -66,12 +66,12 @@
class="js_quantity form-control quantity" class="js_quantity form-control quantity"
t-att-data-line-id="line.id" t-att-data-line-id="line.id"
t-att-data-product-id="line.product_id.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-att-value="line.product_uom_qty == line.product_uom_qty and line.product_uom_qty or line.product_uom_qty"
/> />
</t> </t>
</t> </t>
<t t-else=""> <t t-else="">
<span class="text-muted w-100" t-esc="int(line.product_uom_qty)"/> <span class="text-muted w-100" t-esc="line.product_uom_qty"/>
<input <input
type="hidden" type="hidden"
class="js_quantity form-control quantity" class="js_quantity form-control quantity"