From 6df3ffb81d1fda6d792400ae78c791dca67eb06b Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Mon, 3 Oct 2022 14:09:43 +0000 Subject: [PATCH] [FIX] sale: fix test_pricelist_dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test is failling during nightly mainly when executed arround 23 The most likely reason for that is because of the freezetime rounding the day and creating an error between 23 and 00. The freezetime only wraps the create but the compute will be triggered only after that. Adding all assertions inside the freezetime may be enough to fix this issue. closes odoo/odoo#101989 X-original-commit: 98693d5543e3c0b4f8f51a05e026fce8ddb77a51 Signed-off-by: Xavier Dollé (xdo) --- addons/sale/tests/test_sale_prices.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/addons/sale/tests/test_sale_prices.py b/addons/sale/tests/test_sale_prices.py index fc996f10668..073e4fc4028 100644 --- a/addons/sale/tests/test_sale_prices.py +++ b/addons/sale/tests/test_sale_prices.py @@ -124,17 +124,18 @@ class TestSalePrices(SaleCommon): self.assertEqual(order_line.discount, 0.0) self.empty_order.date_order = False + with freeze_time(today): order_line = self.env['sale.order.line'].create({ 'order_id': self.empty_order.id, 'product_id': self.product.id, }) - self.assertEqual(order_line.pricelist_item_id, pricelist_rule) - self.assertEqual( - order_line.price_unit, - self.product.lst_price * (1 - self.discount / 100.0)) - self.assertEqual(order_line.discount, 0.0) + self.assertEqual(order_line.pricelist_item_id, pricelist_rule) + self.assertEqual( + order_line.price_unit, + self.product.lst_price * (1 - self.discount / 100.0)) + self.assertEqual(order_line.discount, 0.0) with freeze_time(tomorrow): order_line = self.env['sale.order.line'].create({ @@ -142,15 +143,15 @@ class TestSalePrices(SaleCommon): 'product_id': self.product.id, }) - self.assertEqual(order_line.pricelist_item_id, pricelist_rule) - self.assertEqual( - order_line.price_unit, - self.product.lst_price) - self.assertEqual(order_line.discount, 0.0) + self.assertEqual(order_line.pricelist_item_id, pricelist_rule) + self.assertEqual( + order_line.price_unit, + self.product.lst_price) + self.assertEqual(order_line.discount, 0.0) - self.assertEqual( - self.empty_order.amount_untaxed, - self.product.lst_price * 3.8) + self.assertEqual( + self.empty_order.amount_untaxed, + self.product.lst_price * 3.8) def test_pricelist_product_context(self): """ Verify that the product attributes extra prices are correctly considered """