From a3c3518313d6c02f0d1dbdf70403e31ab0cd583b Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 9 Jan 2023 16:57:50 +0000 Subject: [PATCH] [FIX] sale: avoid conflict between demo & test rates When run on new year, the test fails because the created currency rate (for the test) conflicts with the one in the demo data. closes odoo/odoo#109483 X-original-commit: 5a62eb7a25a05c7e779866824e0c1308d558f64a Signed-off-by: Victor Feyens (vfe) --- addons/sale/tests/test_sale_prices.py | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/addons/sale/tests/test_sale_prices.py b/addons/sale/tests/test_sale_prices.py index d0e0cdb2152..22d2eb27b74 100644 --- a/addons/sale/tests/test_sale_prices.py +++ b/addons/sale/tests/test_sale_prices.py @@ -217,25 +217,26 @@ class TestSalePrices(SaleCommon): 'name': 'Test Pricelist (EUR)', 'currency_id': other_currency.id, }) - self.env['res.currency.rate'].create({ - 'name': fields.Date.today(), - 'rate': 2.0, - 'currency_id': other_currency.id, - 'company_id': self.env.company.id, - }) - order_in_other_currency = self.env['sale.order'].create({ - 'partner_id': self.partner.id, - 'pricelist_id': pricelist_in_other_curr.id, - 'order_line': [ - Command.create({ - 'product_id': self.product.id, - 'product_uom': self.uom_dozen.id, - 'product_uom_qty': 2.0, - }), - ] - }) - # 20.0 (product price) * 24.0 (2 dozens) * 2.0 (price rate USD -> EUR) - self.assertEqual(order_in_other_currency.amount_total, 960.0) + with freeze_time('2022-08-19'): + self.env['res.currency.rate'].create({ + 'name': fields.Date.today(), + 'rate': 2.0, + 'currency_id': other_currency.id, + 'company_id': self.env.company.id, + }) + order_in_other_currency = self.env['sale.order'].create({ + 'partner_id': self.partner.id, + 'pricelist_id': pricelist_in_other_curr.id, + 'order_line': [ + Command.create({ + 'product_id': self.product.id, + 'product_uom': self.uom_dozen.id, + 'product_uom_qty': 2.0, + }), + ] + }) + # 20.0 (product price) * 24.0 (2 dozens) * 2.0 (price rate USD -> EUR) + self.assertEqual(order_in_other_currency.amount_total, 960.0) def test_negative_discounts(self): """aka surcharges"""