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

base: don't allow selecting draft currencies by default

The initial intention was to "disallow invalidated", without forcing users to
validate everything, but it was probably a mistake, if users don't need to
validate then validation workflow would be a bit meaningless.

This is made after an incident where a user mistakenly cloned a validated
currency and the cloned currency was available everywhere in the system.

Change to not return draft currencies by default and also change so that all
items are tuple, for consistency. That should have no impact and is a bit
easier for the test.

Also adjust accounting_ui_test, we need to validate currencies for the tests
and clear cache if we validated some (but we don't need to clear cache if we
validate accounts, because account caches is more clever and does not need to
clear all cache)
parent 4e1b5f93
......@@ -6,16 +6,20 @@ for rule in portal.portal_rules.objectValues():
if rule.getValidationState() != 'validated':
rule.validate()
# open all accounts, and clear cache if we have validated some new accounts
validated = False
for account in portal.account_module.objectValues():
if account.getValidationState() != 'validated':
account.validate()
# validate currencies and clear cache if we have validated new currencies
for currency in portal.currency_module.objectValues():
if currency.getValidationState() != 'validated':
currency.validate()
validated = True
if validated:
portal.portal_caches.clearCache(cache_factory_list=('erp5_content_long', ))
portal.portal_caches.clearCache(cache_factory_list=('erp5_ui_short', ))
# validate all accounts
for account in portal.account_module.objectValues():
if account.getValidationState() != 'validated':
account.validate()
# validate third parties and set them a dummy region, because it's required
for entity in ( portal.organisation_module.objectValues() +
......
......@@ -7,7 +7,7 @@ portal = context.getPortalObject()
def getCurrencyItemList(include_empty=1, validation_state=validation_state):
result = []
if include_empty :
result = [['', ''],]
result = [('', ''),]
currency_module = portal.restrictedTraverse(
'currency_module',
portal.restrictedTraverse('currency', None))
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>include_empty=1, validation_state=(\'validated\', \'draft\', \'published\')</string> </value>
<value> <string>include_empty=1, validation_state=(\'validated\', \'published\')</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -1116,6 +1116,30 @@ class TestERP5Base(ERP5TypeTestCase):
bank_account.Base_createCloneDocument()
self.assertEqual(2, len(person))
def test_CurrencyModule_getCurrencyItemList(self):
currency_module = self.portal.currency_module
currency_module.newContent(
portal_type='Currency',
id='validated',
title='Validated',
reference='VA',
).validate()
invalidated = currency_module.newContent(
portal_type='Currency',
title='Invalidated',
reference='INV',
)
invalidated.validate()
invalidated.invalidate()
currency_module.newContent(
portal_type='Currency',
title='Draft',
reference='DRAFT',
)
self.assertEqual(
currency_module.CurrencyModule_getCurrencyItemList(),
[('', ''), ('VA', 'currency_module/validated')])
def getWorkflowHistory(self, document, workflow_id):
return self.portal.portal_workflow.getInfoFor(ob=document, name='history',
wf_id=workflow_id)
......
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