From 2fd9f4e2351b4031c7984626368cdabdf8e81f64 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 16 Aug 2023 16:08:43 +0000 Subject: [PATCH] [FIX] account_global_discount: Make tests resilient - Depending on the installed set of modules, the company currency may be USD or EUR. If the second case, these tests will fail, so we make sure that the company currency is USD for our tests, doing the change by SQL, as there's a Python constraint that prevents it. Not needed in v17 due to: odoo/odoo#107113. --- account_global_discount/tests/test_global_discount.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/account_global_discount/tests/test_global_discount.py b/account_global_discount/tests/test_global_discount.py index c0b346e8668..a491b9c054d 100644 --- a/account_global_discount/tests/test_global_discount.py +++ b/account_global_discount/tests/test_global_discount.py @@ -17,6 +17,16 @@ def setUpClass(cls, chart_template_ref=None): cls.env.ref("base_global_discount.group_global_discount").write( {"users": [(4, cls.env.user.id)]} ) + cls.currency_eur = cls.env.ref("base.EUR") + cls.currency_usd = cls.env.ref("base.USD") + cls.currency_usd.active = True + # Make sure the currency of the company is USD, as this not always happens + # To be removed in V17: https://github.com/odoo/odoo/pull/107113 + cls.company = cls.env.company + cls.env.cr.execute( + "UPDATE res_company SET currency_id = %s WHERE id = %s", + (cls.env.ref("base.USD").id, cls.company.id), + ) cls.account = cls.env["account.account"].create( { "name": "Test account",