Commit 3fd3859f authored by Tomáš Peterka's avatar Tomáš Peterka

[accounting_test] Make sure right ledgets are on Accounting Transaction Type

parent 13b358cb
......@@ -24,19 +24,24 @@ if with_ledger:
extra_kwargs_general = {'ledger': 'accounting/general'}
extra_kwargs_detailed = {'ledger': 'accounting/detailed'}
accounting_ledger = ledger.get('accounting', None) \
or ledger.newContent(portal_type='Category', id='accounting')
accounting_ledger = ledger.get('accounting', None)
if accounting_ledger is None:
accounting_ledger = ledger.newContent(portal_type='Category', id='accounting')
if accounting_ledger.get('general', None) is None:
accounting_ledger.newContent(portal_type='Category', id='general')
if accounting_ledger.get('detailed', None) is None:
accounting_ledger.newContent(portal_type='Category', id='detailed')
for sub_category_name in ('general', 'detailed'):
sub_category = accounting_ledger.get(sub_category_name, None)
if sub_category is None:
sub_category = accounting_ledger.newContent(portal_type='Category', id=sub_category_name)
# necessary for the "ledger" form field to appear and have correct options
accounting_transaction = portal.portal_types.get('Accounting Transaction')
if not accounting_transaction.getLedgerList():
accounting_transaction.setProperty(
"ledger_list", ['accounting/general', 'accounting/detailed'])
ledger_list = accounting_transaction.getLedgerList()
if 'accounting/general' not in ledger_list:
ledger_list.append('accounting/general')
if 'accounting/detailed' not in ledger_list:
ledger_list.append('accounting/detailed')
accounting_transaction.setLedgerList(ledger_list)
else:
extra_kwargs_general = {}
extra_kwargs_detailed = {}
......
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