Commit 40232f71 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

base: fix CurrencyConstraint

It was using "Reference" instead of the dedicated term "Currency Code".

Attribute Unicity constraint message was not correctly including the
reference, the error message was always "Another currency with reference
None already exists".
parent 79d4c67b
......@@ -38,7 +38,7 @@
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Reference must be defined</string> </value>
<value> <string>Currency Code must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -18,6 +18,14 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>reference</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......@@ -26,7 +34,7 @@
</item>
<item>
<key> <string>filter_parameter</string> </key>
<value> <string>python: {\'portal_type\': (\'Currency\', ), \'validation_state\': (\'validated\', ),\'reference\': object.getReference()}</string> </value>
<value> <string>python: {\'portal_type\': (\'Currency\', ), \'validation_state\': (\'validated\', ), \'reference\': object.getReference()}</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -34,7 +42,7 @@
</item>
<item>
<key> <string>message_invalid_attribute_unicity</string> </key>
<value> <string>Another currency with reference ${value} already exists</string> </value>
<value> <string>Another currency with Currency Code ${value} already exists</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -1231,6 +1231,31 @@ class TestERP5Base(ERP5TypeTestCase):
currency_module.CurrencyModule_getCurrencyItemList(),
[('', ''), ('VA', 'currency_module/validated')])
def test_CurrencyConstraint(self):
self._addPropertySheet('Currency', 'CurrencyConstraint')
currency_module = self.portal.currency_module
existing_currency = currency_module.newContent(
portal_type='Currency',
reference='CODE',
)
existing_currency.validate()
self.tic()
def cleanup():
self.portal.currency_module.manage_delObjects([existing_currency.getId()])
self.tic()
self.addCleanup(cleanup)
currency = currency_module.newContent(
portal_type='Currency',
)
self.assertIn(
'Currency Code must be defined',
[str(m.getMessage()) for m in currency.checkConsistency()])
currency.setReference('CODE')
self.assertIn(
'Another currency with Currency Code CODE already exists',
[str(m.getMessage()) for m in currency.checkConsistency()])
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