[ADD] base_global_discount: New Module 11.0

This commit is contained in:
David
2019-08-21 12:36:02 +02:00
committed by Omar (Comunitea)
parent b21ae62496
commit db964544d7
20 changed files with 715 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import test_global_discount

View 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)