[Erp5-report] r34526 jerome - in /erp5/trunk/bt5/erp5_accounting: SkinTemplateItem/portal_s...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 13 18:33:26 CEST 2010


Author: jerome
Date: Tue Apr 13 18:33:23 2010
New Revision: 34526

URL: http://svn.erp5.org?rev=34526&view=rev
Log:
to get the currency for a section, iterate the group top down until we find one organisation with an accounting currency defined

Modified:
    erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision

Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml?rev=34526&r1=34525&r2=34526&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml [utf8] Tue Apr 13 18:33:23 2010
@@ -57,8 +57,7 @@
 \n
 If the section is an organisation, returns this organisation\'s accounting\n
 currency.\n
-If the section is a category, if the category have a mapping organisation,\n
-return this organisation\'s currency.\n
+If the section is a category, find the most suitable currency.\n
 """\n
 \n
 def getCurrencyForSection(section_url):\n
@@ -69,18 +68,30 @@
     return section.getPriceCurrency()\n
 \n
   if section.getPortalType() == \'Category\':\n
+    # first get the strict one\n
     member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\n
+                                                   strict_membership=True,\n
                                                    checked_permission=\'View\')\n
-    if len(member_list) == 1 and member_list[0].getPriceCurrency():\n
-      return member_list[0].getPriceCurrency()\n
+    for member in member_list:\n
+      currency = member.getPriceCurrency()\n
+      if currency:\n
+        return currency\n
+\n
+    # then from mapping category\n
     mapping = section.getMappingValue(portal_type=\'Organisation\')\n
     if mapping is not None and mapping.getPriceCurrency():\n
       return mapping.getPriceCurrency()\n
-    for member in member_list:\n
-      if member.getPriceCurrency():\n
-        return member.getPriceCurrency()\n
-  # nothing found ... returns the currency from preferences.\n
-  return portal.portal_preferences.getPreferredAccountingTransactionCurrency()\n
+\n
+    # otherwise, lookup all groups top down until we find one currency\n
+    for subsection in section.getCategoryChildValueList(local_sort_id=\'int_index\'):\n
+      member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\',\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
 from Products.ERP5Type.Cache import CachingMethod\n
 getCurrencyForSection = CachingMethod(getCurrencyForSection,\n

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=34526&r1=34525&r2=34526&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision [utf8] Tue Apr 13 18:33:23 2010
@@ -1,1 +1,1 @@
-1173
+1175




More information about the Erp5-report mailing list