You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.2 KiB

  1. # Copyright 2019 Tecnativa - David Vidal
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo.tests import common
  4. class TestGlobalDiscount(common.SavepointCase):
  5. @classmethod
  6. def setUpClass(cls):
  7. super().setUpClass()
  8. cls.global_discount_obj = cls.env["global.discount"]
  9. cls.global_discount_1 = cls.global_discount_obj.create(
  10. {"name": "Test Discount 1", "discount_scope": "sale", "discount": 20}
  11. )
  12. cls.global_discount_2 = cls.global_discount_obj.create(
  13. {"name": "Test Discount 2", "discount_scope": "sale", "discount": 30}
  14. )
  15. def test_01_global_discounts(self):
  16. """Chain two discounts of different types"""
  17. discount_vals = self.global_discount_1._get_global_discount_vals(100.0)
  18. self.assertAlmostEqual(discount_vals["base_discounted"], 80.0)
  19. discount_vals = self.global_discount_2._get_global_discount_vals(
  20. discount_vals["base_discounted"]
  21. )
  22. self.assertAlmostEqual(discount_vals["base_discounted"], 56.0)
  23. def test_02_display_name(self):
  24. """Test that the name is computed fine"""
  25. self.assertTrue("%)" in self.global_discount_1.display_name)