From 11bab672cf3af52ceead93d1bf91d1ea8d01d4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 20 Nov 2021 00:14:56 +0100 Subject: [PATCH] Round price to 2 digits Shopify supports only 2 decimal digits for price and have weird parsing issue when more digits are set to the string. issue10960 review375971002 --- product.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/product.py b/product.py index a78bcb33a4..a26b6b681a 100644 --- a/product.py +++ b/product.py @@ -1,5 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +from decimal import Decimal + import shopify import pyactiveresource @@ -205,7 +207,10 @@ class Product(IdentifiersMixin, metaclass=PoolMeta): variant.sku = self.shopify_sku price = self.shopify_price( price, tax, taxes_included=shop_taxes_included) - variant.price = str(price) if price is not None else None + if price is not None: + variant.price = str(price.quantize(Decimal('.00'))) + else: + variant.price = None variant.taxable = bool(tax) for identifier in self.identifiers: if identifier.type == 'ean':