[Erp5-report] r12420 - in /erp5/trunk/bt5/erp5_accounting: SkinTemplateItem/portal_skins/er...
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jan 29 11:42:29 CET 2007
Author: jerome
Date: Mon Jan 29 11:42:25 2007
New Revision: 12420
URL: http://svn.erp5.org?rev=12420&view=rev
Log:
Guess the applicable currency and use this currency precision to round values
and set 'precision' on float fields.
Added:
erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml
Modified:
erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml
erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml
erp5/trunk/bt5/erp5_accounting/bt/revision
Added: 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=12420&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml (added)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Base_getCurrencyForSection.xml Mon Jan 29 11:42:25 2007
@@ -1,0 +1,182 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <tuple>
+ <string>Products.PythonScripts.PythonScript</string>
+ <string>PythonScript</string>
+ </tuple>
+ <none/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>Python_magic</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>Script_magic</string> </key>
+ <value> <int>3</int> </value>
+ </item>
+ <item>
+ <key> <string>__ac_local_roles__</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_bind_names</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>_asgns</string> </key>
+ <value>
+ <dictionary>
+ <item>
+ <key> <string>name_container</string> </key>
+ <value> <string>container</string> </value>
+ </item>
+ <item>
+ <key> <string>name_context</string> </key>
+ <value> <string>context</string> </value>
+ </item>
+ <item>
+ <key> <string>name_m_self</string> </key>
+ <value> <string>script</string> </value>
+ </item>
+ <item>
+ <key> <string>name_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>_body</string> </key>
+ <value> <string>"""Returns the most suitable currency for a section.\n
+\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
+"""\n
+\n
+def getCurrencyForSection(section_url):\n
+ portal = context.getPortalObject()\n
+ section = portal.portal_categories.restrictedTraverse(section_url)\n
+\n
+ if section.getPortalType() == \'Organisation\':\n
+ return section.getPriceCurrency()\n
+\n
+ if section.getPortalType() == \'Category\':\n
+ member_list = section.getGroupRelatedValueList(portal_type=\'Organisation\')\n
+ if len(member_list) == 1:\n
+ return member_list[0].getPriceCurrency()\n
+ mapping = section.getMappingValue(portal_type=\'Organisation\')\n
+ if mapping is not None:\n
+ return mapping.getPriceCurrency()\n
+\n
+ # nothing found ... returns the currency from preferences.\n
+ return portal.portal_preferences.getPreferredAccountingTransactionCurrency()\n
+\n
+from Products.ERP5Type.Cache import CachingMethod\n
+getCurrencyForSection = CachingMethod(getCurrencyForSection,\n
+ id=script.getId())\n
+return getCurrencyForSection(section_url)\n
+</string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_filepath</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_owner</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string>section_url</string> </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>1</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>section_url</string>
+ <string>getCurrencyForSection</string>
+ <string>Products.ERP5Type.Cache</string>
+ <string>CachingMethod</string>
+ <string>_getattr_</string>
+ <string>script</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>Base_getCurrencyForSection</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml?rev=12420&r1=12419&r2=12420&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/ERP5Accounting_getParams.xml Mon Jan 29 11:42:25 2007
@@ -80,11 +80,11 @@
"""\n
\n
# do we have a cache already?\n
-# XXX take selection into account ?\n
if not ignore_cache:\n
params_cache = context.REQUEST.other.get(\n
\'ERP5Accounting_getParams\', None)\n
if params_cache is not None:\n
+ # return a copy\n
return dict(params_cache)\n
\n
params = {}\n
@@ -108,11 +108,18 @@
preference.getPreferredAccountingTransactionSectionCategory())\n
if section_category:\n
params[\'section_category\'] = section_category\n
+ currency = context.Base_getCurrencyForSection(section_category)\n
+ # getQuantityPrecisionFromResource is defined on Base, but the portal is not \n
+ # an instance of Base, so we call it on account_module.\n
+ params[\'precision\'] = context.account_module\\\n
+ .getQuantityPrecisionFromResource(currency)\n
+\n
\n
simulation_state = selection_params.get(\'simulation_state\',\n
preference.getPreferredAccountingTransactionSimulationStateList())\n
if simulation_state:\n
params[\'simulation_state\'] = simulation_state\n
+\n
\n
if not ignore_cache:\n
context.REQUEST.other[\'ERP5Accounting_getParams\'] = params\n
@@ -174,6 +181,7 @@
<string>_write_</string>
<string>at_date</string>
<string>section_category</string>
+ <string>currency</string>
<string>simulation_state</string>
</tuple>
</value>
Modified: erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml?rev=12420&r1=12419&r2=12420&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/Node_getAccountingTransactionList.xml Mon Jan 29 11:42:25 2007
@@ -74,6 +74,10 @@
portal = context.getPortalObject()\n
params = portal.ERP5Accounting_getParams(selection)\n
N_ = lambda msg: Message(\'erp5_ui\', msg)\n
+\n
+if params.get(\'precision\', None) is not None:\n
+ # listbox editable float fields uses request/precision to format the value.\n
+ context.REQUEST.set(\'precision\', params[\'precision\'])\n
\n
if not from_date:\n
from_date = portal.portal_preferences\\\n
Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=12420&r1=12419&r2=12420&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision Mon Jan 29 11:42:25 2007
@@ -1,1 +1,1 @@
-161
+165
More information about the Erp5-report
mailing list