summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/website_sale/tests/test_website_sale_pricelist.py8
-rw-r--r--odoo/tools/misc.py12
2 files changed, 13 insertions, 7 deletions
diff --git a/addons/website_sale/tests/test_website_sale_pricelist.py b/addons/website_sale/tests/test_website_sale_pricelist.py
index 8f1179bedb2..59af832fc74 100644
--- a/addons/website_sale/tests/test_website_sale_pricelist.py
+++ b/addons/website_sale/tests/test_website_sale_pricelist.py
@@ -6,6 +6,7 @@ except ImportError:
from mock import patch
from odoo.tests import tagged
from odoo.tests.common import HttpCase, TransactionCase
+from odoo.tools import DotDict
''' /!\/!\
Calling `get_pricelist_available` after setting `property_product_pricelist` on
@@ -157,13 +158,6 @@ def simulate_frontend_context(self, website_id=1):
self.addCleanup(patcher.stop)
-class DotDict(dict):
- """dot.notation access to dictionary attributes"""
- def __getattr__(*args):
- val = dict.get(*args)
- return DotDict(val) if type(val) is dict else val
-
-
@tagged('post_install', '-at_install')
class TestWebsitePriceListAvailable(TransactionCase):
# This is enough to avoid a mock (request.session/website do not exist during test)
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index e828443ae80..44c3dd4bc41 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -1243,3 +1243,15 @@ def wrap_module(module, attr_list):
raise AttributeError(attrib)
# module and attr_list are in the closure
return WrappedModule()
+
+
+class DotDict(dict):
+ """Helper for dot.notation access to dictionary attributes
+
+ E.g.
+ foo = DotDict({'bar': False})
+ return foo.bar
+ """
+ def __getattr__(self, attrib):
+ val = self.get(attrib)
+ return DotDict(val) if type(val) is dict else val