Commit 2d633be9 authored by Jérome Perrin's avatar Jérome Perrin

Share code between InvoiceTransactionLine_getDestinationItemList and

InvoiceTransactionLine_getSourceItemList


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7506 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bcd8dad9
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>Python_magic</string> </key> <key> <string>Python_magic</string> </key>
<value> <string encoding="base64">bfINCg==</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>Script_magic</string> </key> <key> <string>Script_magic</string> </key>
...@@ -66,42 +68,20 @@ ...@@ -66,42 +68,20 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Cache import CachingMethod\n <value> <string>category_dict = {\n
\n \'income\': \'account_type/expense\',\n
category_dict = {\'income\': \'portal_categories/account_type/expense\',\n \'expense\': \'account_type/income\',\n
\'expense\': \'portal_categories/account_type/income\',\n \'payable\': \'account_type/asset/receivable\',\n
\'payable\': \'portal_categories/account_type/asset/receivable\',\n \'receivable\': \'account_type/liability/payable\',\n
\'receivable\': \'portal_categories/account_type/liability/payable\',\n \'collected_vat\': \'account_type/asset/receivable/refundable_vat\',\n
\'collected_vat\': \'portal_categories/account_type/asset/receivable/refundable_vat\',\n \'refundable_vat\': \'account_type/liability/payable/collected_vat\',\n
\'refundable_vat\': \'portal_categories/account_type/liability/payable/collected_vat\',\n \'bank\': \'account_type/asset/cash\',\n
\'bank\': \'portal_categories/account_type/asset/cash\',\n \'cash\': \'account_type/asset/cash\',\n
\'cash\': \'portal_categories/account_type/asset/cash\',\n }\n
}\n
\n
if context.id in category_dict:\n
category = category_dict[context.id]\n
else:\n
category = \'portal_categories/account_type\'\n
\n
display_dict = {}\n
display_funct = context.Account_getFormattedTitle\n
\n
def display(x):\n
display_dict[x] = display_funct(x)\n
return display_dict[x]\n
\n
def sort(x,y):\n
return cmp(display(x), display(y))\n
\n
def getItemList(category=None, portal_path=None):\n
obj = context.restrictedTraverse(category)\n
item_list = obj.getCategoryMemberItemList(portal_type=\'Account\', base=0,\n
display_method=display, sort_method=sort)\n
return item_list\n
\n \n
getItemList = CachingMethod(getItemList, id=(\'getInvoiceTransactionLineItemList\', \'getItemList\'))\n return context.InvoiceTransactionLine_getSourceItemList(\n
portal_path = context.getPortalObject().getPhysicalPath()\n category_dict=category_dict,\n
return getItemList(category=category, portal_path=portal_path)\n caching_method_id=\'InvoiceTransactionLine_getDestinationItemList\' )\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -148,20 +128,9 @@ return getItemList(category=category, portal_path=portal_path)\n ...@@ -148,20 +128,9 @@ return getItemList(category=category, portal_path=portal_path)\n
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>category_dict</string> <string>category_dict</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>_getitem_</string>
<string>category</string>
<string>display_dict</string>
<string>display_funct</string>
<string>display</string>
<string>sort</string>
<string>None</string>
<string>getItemList</string>
<string>portal_path</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>Python_magic</string> </key> <key> <string>Python_magic</string> </key>
<value> <string encoding="base64">bfINCg==</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>Script_magic</string> </key> <key> <string>Script_magic</string> </key>
...@@ -68,42 +70,55 @@ ...@@ -68,42 +70,55 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Cache import CachingMethod\n <value> <string>from Products.ERP5Type.Cache import CachingMethod\n
\n \n
category_dict = {\'income\': \'account_type/income\',\n if category_dict is None:\n
\'expense\': \'account_type/expense\',\n # this code is shared by InvoiceTransactionLine_getSourceItemList, \n
\'payable\': \'account_type/liability/payable\',\n # which provides it\'s own dict\n
\'receivable\': \'account_type/asset/receivable\',\n category_dict = {\n
\'collected_vat\': \'account_type/liability/payable/collected_vat\',\n \'income\': \'account_type/income\',\n
\'refundable_vat\': \'account_type/asset/receivable/refundable_vat\',\n \'expense\': \'account_type/expense\',\n
\'bank\': \'account_type/asset/cash\',\n \'payable\': \'account_type/liability/payable\',\n
}\n \'receivable\': \'account_type/asset/receivable\',\n
category = category_dict.get(context.id, \'account_type\')\n \'collected_vat\': \'account_type/liability/payable/collected_vat\',\n
\'refundable_vat\': \'account_type/asset/receivable/refundable_vat\',\n
\'bank\': \'account_type/asset/cash\',\n
}\n
category = category_dict.get(context.getId(), \'account_type\')\n
\n \n
display_dict = {}\n \n
display_cache = {}\n
display_funct = context.Account_getFormattedTitle\n display_funct = context.Account_getFormattedTitle\n
\n \n
def display(x):\n def display(x):\n
display_dict[x] = display_funct(x)\n if x not in display_cache:\n
return display_dict[x]\n display_cache[x] = display_funct(x)\n
return display_cache[x]\n
\n \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
def getItemList(category=None, portal_path=None, user_name = None, simulation_state = None):\n def getItemList(category=None, portal_path=None, user_name=None, simulation_state=None):\n
"""Returns a list of Account path items. """\n
cat = context.portal_categories.resolveCategory(category)\n cat = context.portal_categories.resolveCategory(category)\n
filter_dict = {}\n filter_dict = {}\n
# we don\'t filter in "old" transactions or report / search dialogs\n \n
# we don\'t filter in existing transactions or report / search dialogs\n
if simulation_state not in (\'delivered\', \'cancelled\', \'no_simulation_state\') :\n if simulation_state not in (\'delivered\', \'cancelled\', \'no_simulation_state\') :\n
filter_dict[\'validation_state\'] = (\'draft\', \'validated\')\n filter_dict[\'validation_state\'] = (\'draft\', \'validated\')\n
\n
item_list = cat.getCategoryMemberItemList(portal_type=\'Account\', base=0,\n item_list = cat.getCategoryMemberItemList(portal_type=\'Account\', base=0,\n
display_method=display, sort_method=sort, filter=filter_dict)\n display_method=display, sort_method=sort, filter=filter_dict)\n
return item_list\n return item_list\n
\n \n
getItemList = CachingMethod(getItemList, id=(\'getInvoiceTransactionLineItemList\', \'getItemList\'))\n # wrap the previous method in a cache\n
portal_path = context.getPortalObject().getPhysicalPath()\n getItemList = CachingMethod(getItemList, id=caching_method_id)\n
\n \n
return getItemList( category=category, portal_path=portal_path, \n # the cache vary with the simulation state of the current transaction,\n
user_name=context.REQUEST.AUTHENTICATED_USER,\n # to display all accounts when the transaction is already delivered.\n
simulation_state = context.getProperty(\'simulation_state\', \'no_simulation_state\') )\n return getItemList( category=category,\n
portal_path=context.getPortalObject().getPhysicalPath(), \n
user_name=context.REQUEST.AUTHENTICATED_USER,\n
simulation_state=context.getProperty(\n
\'simulation_state\', \'no_simulation_state\') )\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -124,7 +139,7 @@ return getItemList( category=category, portal_path=portal_path, \n ...@@ -124,7 +139,7 @@ return getItemList( category=category, portal_path=portal_path, \n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>category_dict=None, caching_method_id=\'InvoiceTransactionLine_getSourceItemList\'</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -144,25 +159,25 @@ return getItemList( category=category, portal_path=portal_path, \n ...@@ -144,25 +159,25 @@ return getItemList( category=category, portal_path=portal_path, \n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>2</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>category_dict</string>
<string>caching_method_id</string>
<string>Products.ERP5Type.Cache</string> <string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string> <string>CachingMethod</string>
<string>category_dict</string> <string>None</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>category</string> <string>category</string>
<string>display_dict</string> <string>display_cache</string>
<string>display_funct</string> <string>display_funct</string>
<string>display</string> <string>display</string>
<string>sort</string> <string>sort</string>
<string>None</string>
<string>getItemList</string> <string>getItemList</string>
<string>portal_path</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -174,7 +189,10 @@ return getItemList( category=category, portal_path=portal_path, \n ...@@ -174,7 +189,10 @@ return getItemList( category=category, portal_path=portal_path, \n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<none/> <tuple>
<none/>
<string>InvoiceTransactionLine_getSourceItemList</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
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