Commit e8d51e8b authored by Jérome Perrin's avatar Jérome Perrin

Validate with period.

Translate portal status messages here.
 FIXME: it will be translated again in form_view.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4750 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 671802cf
...@@ -138,12 +138,6 @@ AAAAU2NyaXB0IChQeXRob24pcwgAAAA8bW9kdWxlPgEAAABzAAAAAA==</string> </value> ...@@ -138,12 +138,6 @@ AAAAU2NyaXB0IChQeXRob24pcwgAAAA8bW9kdWxlPgEAAABzAAAAAA==</string> </value>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_workflow/accounting_workflow/scripts/validateBalanceTransaction</string> </value> <value> <string>Script (Python):/nexedi/portal_workflow/accounting_workflow/scripts/validateBalanceTransaction</string> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change</string> </value> <value> <string>state_change</string> </value>
......
...@@ -73,22 +73,30 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n ...@@ -73,22 +73,30 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
error_message = \'\'\n error_message = \'\'\n
\n \n
# Purchase Invoice Transaction or Sale Invoice Transaction.\n # Purchase Invoice Transaction or Sale Invoice Transaction.\n
transaction = state_change.object\n transaction = state_change[\'object\']\n
skip_period_validation = state_change[\'kwargs\'].get(\'skip_period_validation\', 0)\n
\n \n
if transaction.getStopDate() in (None, \'\') : \n if transaction.getStopDate() in (None, \'\') : \n
error_message = \'date is not defined\'\n error_message = \'date is not defined\'\n
else: \n else: \n
# check the date is not in a closed period\n if not skip_period_validation :\n
for apd in context.portal_catalog(\n valid_date = 0\n
portal_type="Accounting Period Delimiter", \n # check the date is in an opened period\n
simulation_state="delivered") : \n transaction_date = DateTime( transaction.getStopDate().year(),\n
apd = apd.getObject()\n transaction.getStopDate().month(),\n
if apd.getStartDate() < transaction.getStopDate() < apd.getStopDate():\n transaction.getStopDate().day() ) # we don\'t care about hour:minutes\n
error_message = \'date is in a closed period\'\n for apd in context.portal_catalog(\n
portal_type = "Accounting Period", \n
simulation_state = "planned") : \n
apd = apd.getObject()\n
if apd.getStartDate() <= transaction_date <= apd.getStopDate():\n
valid_date = 1\n
if not valid_date :\n
error_message = "Date is not in an openned Accounting Period" \n
\n \n
# Get sections and a currency.\n # Get sections and a currency.\n
source_section = transaction.getSourceSection(portal_type = [\'Organisation\'])\n source_section = transaction.getSourceSection()\n
destination_section = transaction.getDestinationSection(portal_type = [\'Organisation\', \'Person\'])\n destination_section = transaction.getDestinationSection()\n
currency = transaction.getResource()\n currency = transaction.getResource()\n
\n \n
if source_section in (None, \'\'):\n if source_section in (None, \'\'):\n
...@@ -96,51 +104,54 @@ if source_section in (None, \'\'):\n ...@@ -96,51 +104,54 @@ if source_section in (None, \'\'):\n
elif transaction.getPortalType() not in (\'Balance Transaction\', \'Accounting Transaction\'):\n elif transaction.getPortalType() not in (\'Balance Transaction\', \'Accounting Transaction\'):\n
if destination_section in (None, \'\'):\n if destination_section in (None, \'\'):\n
error_message = \'destination_section is not defined\'\n error_message = \'destination_section is not defined\'\n
if transaction.getDestinationSection() not in (None, \'\'):\n
error_message = \'destination_section is not an Organisation or a Person\'\n
elif currency in (None, \'\'):\n elif currency in (None, \'\'):\n
error_message = \'currency is not defined\'\n error_message = \'currency is not defined\'\n
\n \n
if error_message != \'\':\n if error_message != \'\':\n
raise ValidationFailed, \'Action impossible : \' + error_message\n raise ValidationFailed, \'Action impossible : \'+error_message\n
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
<value> <string encoding="base64">YwAAAAAAAAAAAQAAAEAAAABzDQAAAGQBAIQAAFoAAGQAAFMoAgAAAE5jAQAAAA0AAAASAAAAQwAA <value> <string encoding="base64">YwAAAAAAAAAAAQAAAEAAAABzDQAAAG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gKFB5dGhvbilzEwAAAHZhbGlkYXRlVHJhbnNhY3Rpb24B RENXb3JrZmxvd3MQAAAAVmFsaWRhdGlvbkZhaWxlZHMNAAAAZXJyb3JfbWVzc2FnZXMJAAAAX2dl
AAAAcy4AAAANAgYDDwIfAQoDJQAGAxIBQgEOAxsBHgESAhMBCgEfARMBBgEfAQ4BEwEOAg0BKAEA dGl0ZW1fcwsAAAB0cmFuc2FjdGlvbnMJAAAAX2dldGF0dHJfcxYAAABza2lwX3BlcmlvZF92YWxp
AABzEwAAAHZhbGlkYXRlVHJhbnNhY3Rpb24oAQAAAHMTAAAAdmFsaWRhdGVUcmFuc2FjdGlvbigA ZGF0aW9ucwQAAABOb25lcwoAAAB2YWxpZF9kYXRlcwgAAABEYXRlVGltZXMQAAAAdHJhbnNhY3Rp
AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </value> b25fZGF0ZXMJAAAAX2dldGl0ZXJfcwcAAABjb250ZXh0cwMAAABhcGRzDgAAAHNvdXJjZV9zZWN0
aW9ucxMAAABkZXN0aW5hdGlvbl9zZWN0aW9ucwgAAABjdXJyZW5jeSgAAAAAKAAAAABzDwAAAFNj
cmlwdCAoUHl0aG9uKXMTAAAAdmFsaWRhdGVUcmFuc2FjdGlvbgEAAABzOgAAAA0CBgMPASECHwEK
AggBBgIkARsBGwElAAYDEgE2AQ4BCAEOAxIBEgESAhMBCgEfARMBCgETAQ4CDQEoAQAAAHMTAAAA
dmFsaWRhdGVUcmFuc2FjdGlvbigBAAAAcxMAAAB2YWxpZGF0ZVRyYW5zYWN0aW9uKAAAAAAoAAAA
AHMPAAAAU2NyaXB0IChQeXRob24pcwgAAAA8bW9kdWxlPgEAAABzAAAAAA==</string> </value>
</item> </item>
<item> <item>
<key> <string>_dav_writelocks</string> </key> <key> <string>_dav_writelocks</string> </key>
...@@ -159,7 +170,19 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </ ...@@ -159,7 +170,19 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
<value> <value>
<tuple/> <tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -190,9 +213,14 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </ ...@@ -190,9 +213,14 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </
<string>Products.DCWorkflow.DCWorkflow</string> <string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string> <string>ValidationFailed</string>
<string>error_message</string> <string>error_message</string>
<string>_getattr_</string> <string>_getitem_</string>
<string>transaction</string> <string>transaction</string>
<string>_getattr_</string>
<string>skip_period_validation</string>
<string>None</string> <string>None</string>
<string>valid_date</string>
<string>DateTime</string>
<string>transaction_date</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>context</string> <string>context</string>
<string>apd</string> <string>apd</string>
......
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