From e27dc8a1f7d340d4f56ced129a8d92a5771dbb68 Mon Sep 17 00:00:00 2001 From: nie Date: Fri, 2 Oct 2020 10:59:26 +0000 Subject: [PATCH] [FIX] website_sale_stock: float precision issue Steps to reproduce the bug: - Create a product with 123.1 units on hand - Click the eCommerce tab - In Availability, choose "Show inventory on website and prevent sales if not enough stock" - Save - Go to Website Bug: 123.10000000000001 is displayed instead of 123.1 opw:2348216 closes odoo/odoo#59020 X-original-commit: 27ab9dcfbb0c8b0400494eda37eea0fc28940524 Signed-off-by: Nicolas Martinelli (nim) --- addons/website_sale_stock/models/product_template.py | 4 +++- .../src/xml/website_sale_stock_product_availability.xml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/website_sale_stock/models/product_template.py b/addons/website_sale_stock/models/product_template.py index 0562e43ac61..eb7bc12bc99 100644 --- a/addons/website_sale_stock/models/product_template.py +++ b/addons/website_sale_stock/models/product_template.py @@ -27,8 +27,10 @@ class ProductTemplate(models.Model): if combination_info['product_id']: product = self.env['product.product'].sudo().browse(combination_info['product_id']) website = self.env['website'].get_current_website() + virtual_available = product.with_context(warehouse=website.warehouse_id.id).virtual_available combination_info.update({ - 'virtual_available': product.with_context(warehouse=website.warehouse_id.id).virtual_available, + 'virtual_available': virtual_available, + 'virtual_available_formatted': self.env['ir.qweb.field.float'].value_to_html(virtual_available, {'decimal_precision': 'Product Unit of Measure'}), 'product_type': product.type, 'inventory_availability': product.inventory_availability, 'available_threshold': product.available_threshold, diff --git a/addons/website_sale_stock/static/src/xml/website_sale_stock_product_availability.xml b/addons/website_sale_stock/static/src/xml/website_sale_stock_product_availability.xml index 38712f507f4..8bb6682e39e 100644 --- a/addons/website_sale_stock/static/src/xml/website_sale_stock_product_availability.xml +++ b/addons/website_sale_stock/static/src/xml/website_sale_stock_product_availability.xml @@ -6,12 +6,12 @@
- available + available
- available + available
In stock