mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[ADD] base_global_discount: New Module 11.0
This commit is contained in:
1
base_global_discount/tests/__init__.py
Normal file
1
base_global_discount/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_global_discount
|
||||
33
base_global_discount/tests/test_global_discount.py
Normal file
33
base_global_discount/tests/test_global_discount.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright 2019 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestGlobalDiscount(common.SavepointCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.global_discount_obj = cls.env['global.discount']
|
||||
cls.global_discount_1 = cls.global_discount_obj.create({
|
||||
'name': 'Test Discount 1',
|
||||
'discount_scope': 'sale',
|
||||
'discount': 20,
|
||||
})
|
||||
cls.global_discount_2 = cls.global_discount_obj.create({
|
||||
'name': 'Test Discount 2',
|
||||
'discount_scope': 'sale',
|
||||
'discount': 30,
|
||||
})
|
||||
|
||||
def test_01_global_discounts(self):
|
||||
"""Chain two discounts of different types"""
|
||||
discount_vals = self.global_discount_1._get_global_discount_vals(100.0)
|
||||
self.assertAlmostEqual(discount_vals['base_discounted'], 80.0)
|
||||
discount_vals = self.global_discount_2._get_global_discount_vals(
|
||||
discount_vals['base_discounted'])
|
||||
self.assertAlmostEqual(discount_vals['base_discounted'], 56.0)
|
||||
|
||||
def test_02_display_name(self):
|
||||
"""Test that the name is computed fine"""
|
||||
self.assertTrue('%)' in self.global_discount_1.display_name)
|
||||
Reference in New Issue
Block a user