From 8f4b6b25ac5e0070d3c3e0b58c9807af70de65e1 Mon Sep 17 00:00:00 2001 From: Chafique Date: Thu, 25 Feb 2021 10:47:44 +0100 Subject: [PATCH] [14.0][FIX] shopinvader: make the base_pricelist and base_pricelist.currency_id fields defined in the tests usable globally --- shopinvader/tests/common.py | 4 ++-- shopinvader/tests/test_product.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/shopinvader/tests/common.py b/shopinvader/tests/common.py index b62dfff1cd..a6d53d9b01 100644 --- a/shopinvader/tests/common.py +++ b/shopinvader/tests/common.py @@ -162,8 +162,8 @@ def setUpClass(cls): ] ) cls.env.user.company_id.currency_id = cls.env.ref("base.USD") - base_price_list = cls.env.ref("product.list0") - base_price_list.currency_id = cls.env.ref("base.USD") + cls.base_pricelist = cls.env.ref("product.list0") + cls.base_pricelist.currency_id = cls.env.ref("base.USD") cls.shopinvader_variant.record_id.currency_id = cls.env.ref("base.USD") diff --git a/shopinvader/tests/test_product.py b/shopinvader/tests/test_product.py index 4e8dfecaf5..eb7fa22d15 100644 --- a/shopinvader/tests/test_product.py +++ b/shopinvader/tests/test_product.py @@ -86,10 +86,11 @@ def test_product_name_url(self): return def test_product_get_price(self): - # base_price_list doesn't define a tax mapping. We are tax included - base_price_list = self.env.ref("product.list0") + # self.base_pricelist doesn't define a tax mapping. We are tax included fiscal_position_fr = self.env.ref("shopinvader.fiscal_position_0") - price = self.shopinvader_variant._get_price(base_price_list, fiscal_position_fr) + price = self.shopinvader_variant._get_price( + self.base_pricelist, fiscal_position_fr + ) self.assertDictEqual( price, { @@ -117,7 +118,7 @@ def test_product_get_price(self): # excluded tax_exclude_fiscal_position = self.env.ref("shopinvader.fiscal_position_1") price = self.shopinvader_variant._get_price( - base_price_list, tax_exclude_fiscal_position + self.base_pricelist, tax_exclude_fiscal_position ) self.assertDictEqual( price, @@ -144,12 +145,13 @@ def test_product_get_price(self): def test_product_get_price_discount_policy(self): # Ensure that discount is with 2 digits self.env.ref("product.decimal_discount").digits = 2 - # base_price_list doesn't define a tax mapping. We are tax included + # self.base_pricelist doesn't define a tax mapping. We are tax included # we modify the discount_policy - base_price_list = self.env.ref("product.list0") - base_price_list.discount_policy = "without_discount" + self.base_pricelist.discount_policy = "without_discount" fiscal_position_fr = self.env.ref("shopinvader.fiscal_position_0") - price = self.shopinvader_variant._get_price(base_price_list, fiscal_position_fr) + price = self.shopinvader_variant._get_price( + self.base_pricelist, fiscal_position_fr + ) self.assertDictEqual( price, { @@ -181,7 +183,7 @@ def test_product_get_price_discount_policy(self): # the original value tax_exclude_fiscal_position = self.env.ref("shopinvader.fiscal_position_1") price = self.shopinvader_variant._get_price( - base_price_list, tax_exclude_fiscal_position + self.base_pricelist, tax_exclude_fiscal_position ) self.assertDictEqual( price,