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