Commit 055ee6e5 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Allow a default precision to be specified.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39078 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d055086f
......@@ -3482,7 +3482,7 @@ class Base( CopyContainer,
self.id = self.id
# Helpers
def getQuantityPrecisionFromResource(self, resource):
def getQuantityPrecisionFromResource(self, resource, d=2):
"""
Provides a quick access to precision without accessing the resource
value in ZODB. Here resource is the relative_url of the resource, such as
......@@ -3493,14 +3493,17 @@ class Base( CopyContainer,
resource_value = self.portal_categories.resolveCategory(resource)
if resource_value is not None:
return resource_value.getQuantityPrecision()
return 0
return None
cached_getQuantityPrecisionFromResource = CachingMethod(
cached_getQuantityPrecisionFromResource,
id='Base_getQuantityPrecisionFromResource',
cache_factory='erp5_content_short')
return cached_getQuantityPrecisionFromResource(resource)
precision = cached_getQuantityPrecisionFromResource(resource)
if precision is None:
precision = d
return precision
# Documentation Helpers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment