From a97922635dcfb098a4b5f58ce44c2b19c140d8db Mon Sep 17 00:00:00 2001 From: "Valentin Vallaeys (vava)" Date: Mon, 2 Jan 2023 14:48:37 +0000 Subject: [PATCH] [FIX] payment: test with correct currency rates Following the standardization of the demo data in https://github.com/odoo/odoo/commit/3752b3166ec6bbb5c6ea55f96bb521381bf2b2d9, some bugs remained in case the currency of the company was changed. closes odoo/odoo#108943 Signed-off-by: Victor Feyens (vfe) --- addons/payment/tests/test_payment_provider.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/payment/tests/test_payment_provider.py b/addons/payment/tests/test_payment_provider.py index ecca2f7cb6c..cd0233ef68f 100644 --- a/addons/payment/tests/test_payment_provider.py +++ b/addons/payment/tests/test_payment_provider.py @@ -104,6 +104,11 @@ class TestPaymentProvider(PaymentCommon): def test_fees_with_currency_conversion(self): """ Test that the conversion of the fees is correctly computed. """ + # Some modules change the company settings and may make this test useless. + if self.currency_euro == self.provider.main_currency_id or ( + self.country_france == self.provider.company_id.country_id + ): + return self.provider.write({ 'fees_active': True, 'fees_dom_fixed': 0., @@ -114,7 +119,7 @@ class TestPaymentProvider(PaymentCommon): with patch( 'odoo.addons.base.models.res_currency.Currency._get_rates', - return_value={self.currency_euro.id: 2., self.currency_usd.id: 1.}, + return_value={self.currency_euro.id: 2., self.provider.main_currency_id.id: 1.}, ): transaction_fees = self.currency.round( self.provider._compute_fees(self.amount, self.currency_euro, self.country_france)