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>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_workflow/accounting_workflow/scripts/validateBalanceTransaction</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
......
......@@ -73,22 +73,30 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
error_message = \'\'\n
\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
if transaction.getStopDate() in (None, \'\') : \n
error_message = \'date is not defined\'\n
else: \n
# check the date is not in a closed period\n
for apd in context.portal_catalog(\n
portal_type="Accounting Period Delimiter", \n
simulation_state="delivered") : \n
apd = apd.getObject()\n
if apd.getStartDate() < transaction.getStopDate() < apd.getStopDate():\n
error_message = \'date is in a closed period\'\n
if not skip_period_validation :\n
valid_date = 0\n
# check the date is in an opened period\n
transaction_date = DateTime( transaction.getStopDate().year(),\n
transaction.getStopDate().month(),\n
transaction.getStopDate().day() ) # we don\'t care about hour:minutes\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
# Get sections and a currency.\n
source_section = transaction.getSourceSection(portal_type = [\'Organisation\'])\n
destination_section = transaction.getDestinationSection(portal_type = [\'Organisation\', \'Person\'])\n
source_section = transaction.getSourceSection()\n
destination_section = transaction.getDestinationSection()\n
currency = transaction.getResource()\n
\n
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
if destination_section in (None, \'\'):\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
error_message = \'currency is not defined\'\n
\n
if error_message != \'\':\n
raise ValidationFailed, \'Action impossible : \' + error_message\n
raise ValidationFailed, \'Action impossible : \'+error_message\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value> <string encoding="base64">YwAAAAAAAAAAAQAAAEAAAABzDQAAAGQBAIQAAFoAAGQAAFMoAgAAAE5jAQAAAA0AAAASAAAAQwAA
AHPoAQAAZAEAawAAbAEAfQIAAWQCAH0DAHQDAHwAAGQDAIMCAH0FAHQDAHwFAGQEAIMCAIMAAHQG
AGQCAGYCAGoGAG8KAAFkBQB9AwBujgABeIoAdAcAdAMAdAgAZAYAgwIAZAcAZAgAZAkAZAoAgwAC
gwEARF1kAH0JAHQDAHwJAGQLAIMCAIMAAH0JAHQDAHwJAGQMAIMCAIMAAHQDAHwFAGQEAIMCAIMA
AAQDagAAbxYAAXQDAHwJAGQEAIMCAIMAAGoAAG4CAAIBbwoAAWQNAH0DAHFwAAFxcABXdAMAfAUA
ZA4AgwIAZAcAZA8AZwEAgwABfQoAdAMAfAUAZBAAgwIAZAcAZA8AZBEAZwIAgwABfQsAdAMAfAUA
ZBIAgwIAgwAAfQwAfAoAdAYAZAIAZgIAagYAbwoAAWQTAH0DAG6HAAF0AwB8BQBkFACDAgCDAABk
FQBkFgBmAgBqBwBvZwABfAsAdAYAZAIAZgIAagYAbzMAAWQXAH0DAHQDAHwFAGQQAIMCAIMAAHQG
AGQCAGYCAGoHAG8KAAFkGAB9AwBxwgEBccYB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fZGF0ZXMJAAAAX2dldGl0ZXJfcwcAAABjb250ZXh0cwMAAABhcGRzDgAAAHNvdXJjZV9zZWN0
aW9ucxMAAABkZXN0aW5hdGlvbl9zZWN0aW9ucwgAAABjdXJyZW5jeSgAAAAAKAAAAABzDwAAAFNj
cmlwdCAoUHl0aG9uKXMTAAAAdmFsaWRhdGVUcmFuc2FjdGlvbgEAAABzOgAAAA0CBgMPASECHwEK
AggBBgIkARsBGwElAAYDEgE2AQ4BCAEOAxIBEgESAhMBCgEfARMBCgETAQ4CDQEoAQAAAHMTAAAA
dmFsaWRhdGVUcmFuc2FjdGlvbigBAAAAcxMAAAB2YWxpZGF0ZVRyYW5zYWN0aW9uKAAAAAAoAAAA
AHMPAAAAU2NyaXB0IChQeXRob24pcwgAAAA8bW9kdWxlPgEAAABzAAAAAA==</string> </value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
......@@ -159,7 +170,19 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </
<item>
<key> <string>_proxy_roles</string> </key>
<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>
</item>
<item>
......@@ -190,9 +213,14 @@ AAAAKAAAAABzDwAAAFNjcmlwdCAoUHl0aG9uKXMIAAAAPG1vZHVsZT4BAAAAcwAAAAA=</string> </
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>error_message</string>
<string>_getattr_</string>
<string>_getitem_</string>
<string>transaction</string>
<string>_getattr_</string>
<string>skip_period_validation</string>
<string>None</string>
<string>valid_date</string>
<string>DateTime</string>
<string>transaction_date</string>
<string>_getiter_</string>
<string>context</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