Commit f24cada6 authored by Jérome Perrin's avatar Jérome Perrin

to get the currency for a section, iterate the group top down until we find...

to get the currency for a section, iterate the group top down until we find one organisation with an accounting currency defined

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34526 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 62506246
...@@ -57,8 +57,7 @@ ...@@ -57,8 +57,7 @@
\n \n
If the section is an organisation, returns this organisation\'s accounting\n If the section is an organisation, returns this organisation\'s accounting\n
currency.\n currency.\n
If the section is a category, if the category have a mapping organisation,\n If the section is a category, find the most suitable currency.\n
return this organisation\'s currency.\n
"""\n """\n
\n \n
def getCurrencyForSection(section_url):\n def getCurrencyForSection(section_url):\n
...@@ -69,18 +68,30 @@ def getCurrencyForSection(section_url):\n ...@@ -69,18 +68,30 @@ def getCurrencyForSection(section_url):\n
return section.getPriceCurrency()\n return section.getPriceCurrency()\n
\n \n
if section.getPortalType() == \'Category\':\n if section.getPortalType() == \'Category\':\n
# first get the strict one\n
member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\n member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\n
strict_membership=True,\n
checked_permission=\'View\')\n checked_permission=\'View\')\n
if len(member_list) == 1 and member_list[0].getPriceCurrency():\n for member in member_list:\n
return member_list[0].getPriceCurrency()\n currency = member.getPriceCurrency()\n
if currency:\n
return currency\n
\n
# then from mapping category\n
mapping = section.getMappingValue(portal_type=\'Organisation\')\n mapping = section.getMappingValue(portal_type=\'Organisation\')\n
if mapping is not None and mapping.getPriceCurrency():\n if mapping is not None and mapping.getPriceCurrency():\n
return mapping.getPriceCurrency()\n return mapping.getPriceCurrency()\n
for member in member_list:\n \n
if member.getPriceCurrency():\n # otherwise, lookup all groups top down until we find one currency\n
return member.getPriceCurrency()\n for subsection in section.getCategoryChildValueList(local_sort_id=\'int_index\'):\n
# nothing found ... returns the currency from preferences.\n member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\n
return portal.portal_preferences.getPreferredAccountingTransactionCurrency()\n strict_membership=True,\n
checked_permission=\'View\')\n
for member in member_list:\n
currency = member.getPriceCurrency()\n
if currency:\n
return currency\n
\n
\n \n
from Products.ERP5Type.Cache import CachingMethod\n from Products.ERP5Type.Cache import CachingMethod\n
getCurrencyForSection = CachingMethod(getCurrencyForSection,\n getCurrencyForSection = CachingMethod(getCurrencyForSection,\n
......
1173 1175
\ No newline at end of file \ No newline at end of file
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