Commit 1682f73a authored by Jérome Perrin's avatar Jérome Perrin

remove usless scripts

* Base_getPreferredPrecision: there are no such thing as a global preferred
  precision. We should use the precision of the resource or price currency
  depending on whether we display quantities or prices.
* Base_getRoundValue: just call round or use precision= parameter from
  inventory API
parent e60dde57
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>portal = context.getPortalObject()\n
Base_translateString = portal.Base_translateString\n
\n
currency = context.portal_preferences.getPreferredAccountingTransactionCurrency()\n
if currency is None:\n
raise ValueError, Base_translateString("Currency must be defined in preferences.")\n
\n
currency_value = context.restrictedTraverse(currency)\n
precision = currency_value.getQuantityPrecision()\n
\n
return precision\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getPreferredPrecision</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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 encoding="cdata"><![CDATA[
try:\n
# Round the value\n
# Fortunately, the round() python method follow french fiscal rules.\n
# Exemples:\n
# 116.5049 should be rounded to 116.50\n
# 116.505 should be rounded to 116.51\n
# 116.5051 should be rounded to 116.51\n
# Please check in your country if the round() method comply with local accounting and fiscal laws.\n
rounded_value = round(value, precision)\n
\n
# Truncate the rounded value\n
trunc_value = (\'%.\' + str(precision) + \'f\') % rounded_value\n
\n
if as_string:\n
return trunc_value\n
return float(trunc_value)\n
\n
except:\n
context.log("bad convertion >>>", repr(context) + " | " + repr(value) + " | " + repr(precision))\n
return 0.0\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>value, precision, as_string=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getRoundValue</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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