Commit 784c5ab2 authored by Jérome Perrin's avatar Jérome Perrin

accounting: keep "??? (value)" to display invalid bank account

The changes from ae15e7e1 (accounting: show the context when
showing invalid bank accounts, 2022-12-21) were a regression because
with the previous behaviour, by just looking at the transactions,
users could see with the ??? that something was wrong with the bank
account. After these changes they had to open the select element.

This restore somehow the previous behaviour by displaying the label
with ??? marker, but since we have the label, we display the
label (bank account reference) instead of the value (the relative URL)
parent ab137095
...@@ -70,12 +70,14 @@ bank_account_list = [brain.getObject() for brain in sorted( ...@@ -70,12 +70,14 @@ bank_account_list = [brain.getObject() for brain in sorted(
)] )]
def getItemList(bank_account): def getItemList(bank_account, warning=False):
reference = bank_account.getReference() reference = bank_account.getReference()
title = bank_account.getTitle() or bank_account.getSourceFreeText() or bank_account.getSourceTitle() title = bank_account.getTitle() or bank_account.getSourceFreeText() or bank_account.getSourceTitle()
label = title label = title
if reference != title: if reference != title:
label = '{} - {}'.format(reference, title) label = '{} - {}'.format(reference, title)
if warning:
label = '??? ({})'.format(label)
return (label, bank_account.getRelativeUrl()) return (label, bank_account.getRelativeUrl())
...@@ -98,6 +100,6 @@ if base_category is not None: ...@@ -98,6 +100,6 @@ if base_category is not None:
translateString( translateString(
'Invalid bank account from ${entity_title}', 'Invalid bank account from ${entity_title}',
mapping={'entity_title': current_value.getParentTitle()}), None)) mapping={'entity_title': current_value.getParentTitle()}), None))
item_list.append(getItemList(current_value)) item_list.append(getItemList(current_value, warning=True))
return item_list return item_list
...@@ -4988,7 +4988,7 @@ class TestTransactions(AccountingTestCase): ...@@ -4988,7 +4988,7 @@ class TestTransactions(AccountingTestCase):
[ [
('', ''), ('', ''),
('Invalid bank account from Client 1', None), ('Invalid bank account from Client 1', None),
('client_1 bank account', client_1_bank_account.getRelativeUrl()), ('??? (client_1 bank account)', client_1_bank_account.getRelativeUrl()),
], ],
) )
...@@ -5013,7 +5013,7 @@ class TestTransactions(AccountingTestCase): ...@@ -5013,7 +5013,7 @@ class TestTransactions(AccountingTestCase):
[ [
('', ''), ('', ''),
('Invalid bank account from Client 1', None), ('Invalid bank account from Client 1', None),
('client_1 bank account', client_1_bank_account.getRelativeUrl()), ('??? (client_1 bank account)', client_1_bank_account.getRelativeUrl()),
], ],
) )
......
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