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

modify Account_view to be able to associate an Account on multiple accounting...

modify Account_view to be able to associate an Account on multiple accounting plans (from JPS patches)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11837 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 022cbe0a
...@@ -68,7 +68,14 @@ ...@@ -68,7 +68,14 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>display_cache = {}\n <value> <string>"""Return a list of possible GAP categories for a given account.\n
\n
if only_preferred_gap parameter is true, this will return only GAP\n
categories from the GAP set in preferences, otherwise it will return\n
categories from all available GAP.\n
"""\n
\n
display_cache = {}\n
\n \n
def display(x):\n def display(x):\n
if x not in display_cache:\n if x not in display_cache:\n
...@@ -82,20 +89,25 @@ def display(x):\n ...@@ -82,20 +89,25 @@ def display(x):\n
def sort(x,y):\n def sort(x,y):\n
return cmp(display(x), display(y))\n return cmp(display(x), display(y))\n
\n \n
gap_root = context.portal_preferences.getPreferredAccountingTransactionGap() \n def getGapItemList(only_preferred_gap): \n
if gap_root is None:\n ctool = context.getPortalObject().portal_categories\n
return [(\'Set Preferred GAP In preferences !\', \'\')]\n if only_preferred_gap:\n
gap_root = context.getPortalObject().portal_preferences\\\n
.getPreferredAccountingTransactionGap() or\\\n
context.getPortalDefaultGapRoot()\n
return ctool.resolveCategory(gap_root).getCategoryChildItemList(\n
base=0, is_self_excluded=1, display_method=display, sort_method=sort)\n
\n \n
def getGapItemList(gap_root, portal_path): \n result = [] \n
obj = context.portal_categories.resolveCategory(gap_root)\n for country in ctool.gap.contentValues():\n
return obj.getCategoryChildItemList(base=0, display_method=display, sort_method=sort)\n for gap_root in country.contentValues():\n
result.extend(gap_root.getCategoryChildItemList(\n
base=0, is_self_excluded=1, display_method=display, sort_method=sort))\n
return result\n
\n \n
from Products.ERP5Type.Cache import CachingMethod\n from Products.ERP5Type.Cache import CachingMethod\n
getGapItemList = CachingMethod(getGapItemList, id=\'Account_getGapItemList\')\n getGapItemList = CachingMethod(getGapItemList, id=\'Account_getGapItemList\')\n
gap_item_list = getGapItemList(gap_root=gap_root, portal_path=context.portal_url())\n return getGapItemList(only_preferred_gap=only_preferred_gap)\n
\n
# Don\'t return the last item, which is the gap_root (like "fr/pcg")\n
return gap_item_list[:-1]\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -112,7 +124,7 @@ return gap_item_list[:-1]\n ...@@ -112,7 +124,7 @@ return gap_item_list[:-1]\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>only_preferred_gap=1</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -132,24 +144,19 @@ return gap_item_list[:-1]\n ...@@ -132,24 +144,19 @@ return gap_item_list[:-1]\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>only_preferred_gap</string>
<string>display_cache</string> <string>display_cache</string>
<string>display</string> <string>display</string>
<string>sort</string> <string>sort</string>
<string>_getattr_</string>
<string>context</string>
<string>gap_root</string>
<string>None</string>
<string>getGapItemList</string> <string>getGapItemList</string>
<string>Products.ERP5Type.Cache</string> <string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string> <string>CachingMethod</string>
<string>gap_item_list</string>
<string>_getitem_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -161,7 +168,9 @@ return gap_item_list[:-1]\n ...@@ -161,7 +168,9 @@ return gap_item_list[:-1]\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<none/> <tuple>
<int>1</int>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
<?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>N_ = context.Base_translateString\n
split_depth = 2\n
\n
def getSubFieldDict():\n
def getSubFieldDictCache():\n
# Define a dictionary where we store the subfields to display.\n
sub_field_dict = {}\n
# Try to assign each item to a sub field.\n
for item in item_list:\n
# Get value of the item\n
item_value = item[int(not is_right_display)]\n
\n
# Hash key from item_value\n
item_split = item_value.split(\'/\')\n
item_key = \'/\'.join(item_split[:split_depth])\n
\n
# Create a new subfield if necessary\n
if not sub_field_dict.has_key(item_key):\n
# Create property dict (key are field parameters)\n
sub_field_property_dict = default_sub_field_property_dict.copy()\n
sub_field_property_dict[\'key\'] = item_key\n
sub_field_property_dict[\'title\'] = N_("GAP - ${gap_title}", mapping=dict(\n
gap_title=context.portal_categories.resolveCategory(\n
\'gap/%s\' % item_key).getTitle()))\n
sub_field_property_dict[\'required\'] = 0\n
sub_field_property_dict[\'field_type\'] = \'ListField\'\n
sub_field_property_dict[\'size\'] = 1\n
sub_field_property_dict[\'item_list\'] = [(\'\', \'\') ]\n
sub_field_property_dict[\'value\'] = None\n
sub_field_dict[item_key] = sub_field_property_dict\n
\n
sub_field_dict[item_key][\'item_list\'].append(item)\n
sub_field_property_dict[\'size\'] = 1\n
return sub_field_dict\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
getSubFieldDictCache = CachingMethod(getSubFieldDictCache,\n
id=\'Account_getSubFieldDict\')\n
# Those cached dictionnaries are later modified, we just reset the \'value\'\n
# key to return clean dictionnaries.\n
sub_field_dict = getSubFieldDictCache()\n
for k in sub_field_dict.keys():\n
sub_field_dict[k][\'value\'] = None\n
return sub_field_dict\n
\n
sub_field_dict = getSubFieldDict()\n
# Update sub_field_dict with values\n
for item_value in value_list:\n
if item_value:\n
# Hash key from item_value\n
item_split = item_value.split(\'/\')\n
item_key = \'/\'.join(item_split[:split_depth])\n
\n
if not sub_field_dict.has_key(item_key):\n
# This can only happens if an accounting plan have been uninstalled\n
sub_field_property_dict = default_sub_field_property_dict.copy()\n
sub_field_property_dict[\'key\'] = item_key\n
sub_field_property_dict[\'title\'] = item_key\n
sub_field_property_dict[\'required\'] = 0\n
sub_field_property_dict[\'field_type\'] = \'ListField\'\n
sub_field_property_dict[\'size\'] = 1\n
sub_field_property_dict[\'item_list\'] = [(\'\', \'\')]\n
sub_field_property_dict[\'value\'] = None\n
sub_field_dict[item_key] = sub_field_property_dict\n
\n
sub_field_dict[item_key][\'value\'] = item_value\n
\n
# Return the list of subfield configuration.\n
return sub_field_dict.values()\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>_params</string> </key>
<value> <string>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</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>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>item_list</string>
<string>value_list</string>
<string>default_sub_field_property_dict</string>
<string>is_right_display</string>
<string>_getattr_</string>
<string>context</string>
<string>N_</string>
<string>split_depth</string>
<string>getSubFieldDict</string>
<string>sub_field_dict</string>
<string>_getiter_</string>
<string>item_value</string>
<string>item_split</string>
<string>_getitem_</string>
<string>item_key</string>
<string>sub_field_property_dict</string>
<string>_write_</string>
<string>None</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<dictionary/>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Account_hashGapItemList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -92,19 +92,18 @@ ...@@ -92,19 +92,18 @@
<list> <list>
<string>my_title</string> <string>my_title</string>
<string>my_credit_account</string> <string>my_credit_account</string>
<string>my_gap</string> <string>my_gap_list</string>
<string>my_account_type</string> <string>my_account_type</string>
<string>my_financial_section</string> <string>my_financial_section</string>
<string>my_destination_title_list</string> <string>my_destination_title_list</string>
<string>my_translated_validation_state_title</string>
</list> </list>
</value> </value>
</item> </item>
<item> <item>
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list/>
<string>my_translated_validation_state_title</string>
</list>
</value> </value>
</item> </item>
</dictionary> </dictionary>
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<pickle> <pickle>
<tuple> <tuple>
<tuple> <tuple>
<string>Products.Formulator.StandardFields</string> <string>Products.ERP5Form.ParallelListField</string>
<string>ListField</string> <string>ParallelListField</string>
</tuple> </tuple>
<none/> <none/>
</tuple> </tuple>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_gap</string> </value> <value> <string>my_gap_list</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -79,6 +79,10 @@ ...@@ -79,6 +79,10 @@
<key> <string>first_item</string> </key> <key> <string>first_item</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>hash_script_id</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -104,7 +108,7 @@ ...@@ -104,7 +108,7 @@
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>whitespace_preserve</string> </key> <key> <string>view_separator</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -154,6 +158,10 @@ ...@@ -154,6 +158,10 @@
<key> <string>first_item</string> </key> <key> <string>first_item</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>hash_script_id</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -181,7 +189,7 @@ ...@@ -181,7 +189,7 @@
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>whitespace_preserve</string> </key> <key> <string>view_separator</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -201,7 +209,9 @@ ...@@ -201,7 +209,9 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string></string> </value> <value>
<list/>
</value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -231,6 +241,10 @@ ...@@ -231,6 +241,10 @@
<key> <string>first_item</string> </key> <key> <string>first_item</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item>
<key> <string>hash_script_id</string> </key>
<value> <string>Account_hashGapItemList</string> </value>
</item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
...@@ -243,11 +257,11 @@ ...@@ -243,11 +257,11 @@
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>required</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>1</int> </value> <value> <int>5</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -258,8 +272,12 @@ ...@@ -258,8 +272,12 @@
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>whitespace_preserve</string> </key> <key> <string>view_separator</string> </key>
<value> <int>0</int> </value> <value> <string encoding="cdata"><![CDATA[
<br />
]]></string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -281,7 +299,7 @@ ...@@ -281,7 +299,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: here.Account_getGapItemList()</string> </value> <value> <string>python: here.Account_getGapItemList(only_preferred_gap=0)</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
151 152
\ 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