diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml index c28fc77c34e7023d4c5e09b711339ccf501488ff..41cf4b74ad8873bbff0e44115148dc212a444e4f 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml @@ -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 @@ def getCurrencyForSection(section_url):\n 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 diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index 1720e6f2b51113423c4f984f22f83e40da496202..66dae0a0390439afdecd2ea7d5c1eebcf234caf5 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -1173 \ No newline at end of file +1175 \ No newline at end of file