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.

33 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',
  11. 'discount_scope': 'sale',
  12. 'discount': 20,
  13. })
  14. cls.global_discount_2 = cls.global_discount_obj.create({
  15. 'name': 'Test Discount 2',
  16. 'discount_scope': 'sale',
  17. 'discount': 30,
  18. })
  19. def test_01_global_discounts(self):
  20. """Chain two discounts of different types"""
  21. discount_vals = self.global_discount_1._get_global_discount_vals(100.0)
  22. self.assertAlmostEqual(discount_vals['base_discounted'], 80.0)
  23. discount_vals = self.global_discount_2._get_global_discount_vals(
  24. discount_vals['base_discounted'])
  25. self.assertAlmostEqual(discount_vals['base_discounted'], 56.0)
  26. def test_02_display_name(self):
  27. """Test that the name is computed fine"""
  28. self.assertTrue('%)' in self.global_discount_1.display_name)