From ee3ff4e36f2acf009bf931d71623d3122d70f9f0 Mon Sep 17 00:00:00 2001 From: Andrew Gavgavian Date: Wed, 15 Mar 2023 21:55:44 +0000 Subject: [PATCH] [FIX] sale_timesheet: use the currency of the project in tests Currently the profitability test assumes the project is in the USD currency. However, if the companies default currency is something else, the asserts will fail. Here we guarantee that the 0.00 amount will always be in the same currency as the project to allow the tests to pass. opw-3210514 closes odoo/odoo#116773 X-original-commit: 6ad9d1af8d8add56f2b7752632af55c3e66bd148 Signed-off-by: Xavier Bol (xbo) --- addons/sale_timesheet/tests/test_project_update.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/sale_timesheet/tests/test_project_update.py b/addons/sale_timesheet/tests/test_project_update.py index 4b117d68812..07df0184a07 100644 --- a/addons/sale_timesheet/tests/test_project_update.py +++ b/addons/sale_timesheet/tests/test_project_update.py @@ -3,6 +3,7 @@ from freezegun import freeze_time from odoo.tests import tagged +from odoo.tools import format_amount from odoo.addons.project.tests.test_project_update_flow import TestProjectUpdate @tagged('-at_install', 'post_install') @@ -11,12 +12,16 @@ class TestProjectUpdateSaleTimesheet(TestProjectUpdate): def test_project_update_description_profitability(self): self.project_pigs.allow_billable = True template_values = self.env['project.update']._get_template_values(self.project_pigs) + + # Store the formatted amount in the same currency as the project to guarantee the same unit + comparison_amount = format_amount(self.env, 0.0, self.project_pigs.currency_id) + self.assertEqual(template_values['profitability']['costs'], 0.0, "Project costs used in the template should be well defined") - self.assertEqual(template_values['profitability']['costs_formatted'], "$\xa00.00", "Project costs used in the template should be well defined") + self.assertEqual(template_values['profitability']['costs_formatted'], comparison_amount, "Project costs used in the template should be well defined") self.assertEqual(template_values['profitability']['revenues'], 0.0, "Project revenues used in the template should be well defined") - self.assertEqual(template_values['profitability']['revenues_formatted'], "$\xa00.00", "Project revenues used in the template should be well defined") + self.assertEqual(template_values['profitability']['revenues_formatted'], comparison_amount, "Project revenues used in the template should be well defined") self.assertEqual(template_values['profitability']['margin'], 0, "Margin used in the template should be well defined") - self.assertEqual(template_values['profitability']['margin_formatted'], "$\xa00.00", "Margin formatted used in the template should be well defined") + self.assertEqual(template_values['profitability']['margin_formatted'], comparison_amount, "Margin formatted used in the template should be well defined") self.assertEqual(template_values['profitability']['margin_percentage'], "0", "Margin percentage used in the template should be well defined") def test_project_update_panel_profitability_no_billable(self):