Commit 3bf45e81 authored by Jérome Perrin's avatar Jérome Perrin

Improve AccountModule_getBankAccountItemList to prevent displaying deleted bank accounts.

Update AccountingTransaction_getSourcePaymentItemList and AccountingTransaction_getDestinationPaymentItemList to use it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15274 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9d44c79b
......@@ -68,25 +68,35 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
if organisation == \'\' :\n
organisation = context.REQUEST.get(\'organisation\', None)\n
if organisation is None : \n
<value> <string>from ZTUtils import LazyFilter\n
portal = context.getPortalObject()\n
\n
if not organisation:\n
organisation = portal.portal_preferences\\\n
.getPreferredAccountingTransactionSourceSection()\n
\n
organisation = portal.restrictedTraverse(organisation)\n
if not organisation:\n
return [(\'\', \'\')]\n
\n
\n
organisation_value = portal.restrictedTraverse(organisation)\n
item_list = [(\'\', \'\')]\n
for bank in organisation.contentValues(\n
portal_type=portal.getPortalPaymentNodeTypeList()):\n
if bank.getReference() and bank.getReference() != bank.getTitle():\n
item_list.append((\'%s - %s\' % (bank.getReference(),\n
bank.getTitle() or \n
bank.getSourceFreeText() or\n
bank.getSourceTitle()),\n
bank.getRelativeUrl()))\n
for bank in LazyFilter(organisation_value.contentValues(\n
portal_type=portal.getPortalPaymentNodeTypeList()), skip=\'View\'):\n
\n
if skip_invalidated_bank_accounts and bank.getValidationState() == \'invalidated\':\n
continue\n
\n
if bank.getReference() and bank.getTitle() \\\n
and bank.getReference() != bank.getTitle():\n
item_list.append((\'%s - %s\' % ( bank.getReference(),\n
bank.getTitle() or \n
bank.getSourceFreeText() or\n
bank.getSourceTitle()),\n
bank.getRelativeUrl()))\n
else:\n
item_list.append(( bank.getTitle() or \n
item_list.append(( bank.getReference() or\n
bank.getTitle() or \n
bank.getSourceFreeText() or\n
bank.getSourceTitle(),\n
bank.getRelativeUrl() ))\n
......@@ -106,9 +116,15 @@ return item_list\n
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>organisation = \'\'</string> </value>
<value> <string>organisation=None, skip_invalidated_bank_accounts=1</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -128,17 +144,20 @@ return item_list\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>organisation</string>
<string>skip_invalidated_bank_accounts</string>
<string>ZTUtils</string>
<string>LazyFilter</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>None</string>
<string>organisation_value</string>
<string>item_list</string>
<string>_getiter_</string>
<string>bank</string>
......@@ -154,7 +173,8 @@ return item_list\n
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string></string>
<none/>
<int>1</int>
</tuple>
</value>
</item>
......
......@@ -68,26 +68,10 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>def sort(a, b):\n
return cmp(a[0], b[0])\n
\n
item_list = [[\'\', \'\']]\n
\n
entity = context.getDestinationSectionValue()\n
if entity is not None:\n
bank_account_id_list = entity.contentIds(filter={\'portal_type\':\n
entity.getPortalPaymentNodeTypeList()})\n
for bank_account_id in bank_account_id_list:\n
# skip objects we are not allowed to access\n
bank_account = entity.restrictedTraverse(bank_account_id, None)\n
if bank_account is not None and \\\n
bank_account.getValidationState() != \'invalidated\':\n
url = bank_account.getRelativeUrl()\n
label = bank_account.getReference() or bank_account.getTitle()\n
item_list.append([label, url])\n
\n
item_list.sort(sort)\n
return item_list\n
<value> <string>return context.AccountModule_getBankAccountItemList(\n
organisation=context.getDestinationSection(),\n
skip_invalidated_bank_accounts=\n
(context.getSimulationState() != \'delivered\'))\n
</string> </value>
</item>
<item>
......@@ -130,18 +114,8 @@ return item_list\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>sort</string>
<string>item_list</string>
<string>_getattr_</string>
<string>context</string>
<string>entity</string>
<string>None</string>
<string>bank_account_id_list</string>
<string>_getiter_</string>
<string>bank_account_id</string>
<string>bank_account</string>
<string>url</string>
<string>label</string>
</tuple>
</value>
</item>
......
......@@ -68,26 +68,10 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>def sort(a, b):\n
return cmp(a[0], b[0])\n
\n
item_list = [[\'\', \'\']]\n
\n
entity = context.getSourceSectionValue()\n
if entity is not None:\n
bank_account_id_list = entity.contentIds(filter={\'portal_type\':\n
entity.getPortalPaymentNodeTypeList()})\n
for bank_account_id in bank_account_id_list:\n
# skip objects we are not allowed to access\n
bank_account = entity.restrictedTraverse(bank_account_id, None)\n
if bank_account is not None and \\\n
bank_account.getValidationState() != \'invalidated\':\n
url = bank_account.getRelativeUrl()\n
label = bank_account.getReference() or bank_account.getTitle()\n
item_list.append([label, url])\n
\n
item_list.sort(sort)\n
return item_list\n
<value> <string>return context.AccountModule_getBankAccountItemList(\n
  • @jerome (too old commit I know, sorry) I found this by chance and looks inconsistent that AccountingTransaction_getSourcePaymentItemList calls in its context AccountModule_getBankAccountItemList, so I wonder if the latter is indeed expected to be called in account_module generally

  • that's true @georgios.dagkakis ... because AccountModule_getBankAccountItemList does not depend on context, maybe we could rename it ERP5Site_getBankAccountItemList

Please register or sign in to reply
organisation=context.getSourceSection(),\n
skip_invalidated_bank_accounts=\n
(context.getSimulationState() != \'delivered\'))\n
</string> </value>
</item>
<item>
......@@ -130,18 +114,8 @@ return item_list\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>sort</string>
<string>item_list</string>
<string>_getattr_</string>
<string>context</string>
<string>entity</string>
<string>None</string>
<string>bank_account_id_list</string>
<string>_getiter_</string>
<string>bank_account_id</string>
<string>bank_account</string>
<string>url</string>
<string>label</string>
</tuple>
</value>
</item>
......
365
\ No newline at end of file
368
\ 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