Commit 6ce41dba authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

erp5_accounting, erp5_payment_mean: display currently selected Bank Account...

erp5_accounting, erp5_payment_mean: display currently selected Bank Account even if it is invalidated.
parent 87beef4e
...@@ -10,6 +10,9 @@ organisation, using the following policy: ...@@ -10,6 +10,9 @@ organisation, using the following policy:
If organisation is not passed, this script will return all bank accounts If organisation is not passed, this script will return all bank accounts
applicable for section_category and section_category_strict_membership. applicable for section_category and section_category_strict_membership.
If `base_category` is passed, the currently linked bank account with the specified
base_category is anyway included.
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -56,11 +59,19 @@ item_list = [('', '')] ...@@ -56,11 +59,19 @@ item_list = [('', '')]
include_organisation_hierarchy = len(set( include_organisation_hierarchy = len(set(
['/'.join(b.path.split('/')[:-1]) for b in bank_account_list])) > 1 ['/'.join(b.path.split('/')[:-1]) for b in bank_account_list])) > 1
bank_account_list = [brain.getObject() for brain in sorted(
bank_account_list, key=lambda b:b.path
)]
if base_category is not None:
current_value = context.getProperty(base_category + '_value')
if current_value not in bank_account_list:
bank_account_list.append(current_value)
previous_organisation = None previous_organisation = None
# sort bank accounts in a way that bank accounts from the same # sort bank accounts in a way that bank accounts from the same
# organisation are consecutive # organisation are consecutive
for brain in sorted(bank_account_list, key=lambda b:b.path): for bank in bank_account_list:
bank = brain.getObject()
if include_organisation_hierarchy: if include_organisation_hierarchy:
organisation = bank.getParentValue() organisation = bank.getParentValue()
if organisation != previous_organisation: if organisation != previous_organisation:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>organisation=None, skip_invalidated_bank_accounts=0, section_category=None, section_category_strict_membership=False</string> </value> <value> <string>organisation=None, skip_invalidated_bank_accounts=0, section_category=None, section_category_strict_membership=False, base_category=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
return context.AccountModule_getBankAccountItemList( return context.AccountModule_getBankAccountItemList(
organisation=context.getDestinationSection(), organisation=context.getDestinationSection(),
base_category='destination_payment',
skip_invalidated_bank_accounts= skip_invalidated_bank_accounts=
(context.getSimulationState() != 'delivered')) (context.getSimulationState() != 'delivered'))
return context.AccountModule_getBankAccountItemList( return context.AccountModule_getBankAccountItemList(
organisation=context.getSourceSection(), organisation=context.getSourceSection(),
base_category='source_payment',
skip_invalidated_bank_accounts= skip_invalidated_bank_accounts=
(context.getSimulationState() != 'delivered')) (context.getSimulationState() != 'delivered'))
return context.AccountModule_getBankAccountItemList( return context.AccountModule_getBankAccountItemList(
organisation=context.getSourceSection(), organisation=context.getSourceSection(),
base_category='source_payment',
skip_invalidated_bank_accounts= skip_invalidated_bank_accounts=
(context.getValidationState() != 'delivered')) (context.getValidationState() != 'delivered'))
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