Commit 6c0d8278 authored by Sebastien Robin's avatar Sebastien Robin

Include considered accounting date in the error message.

Simplify control flow.
Merge MySQL requests to always use only one instead of 2 in worst case.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15269 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ba6c616e
...@@ -96,17 +96,14 @@ if site is None:\n ...@@ -96,17 +96,14 @@ if site is None:\n
# get only the office, not need of vault\n # get only the office, not need of vault\n
#context.log(\'Baobab_checkAccountingDateOpen\', \'get site for vault %s\' %(site))\n #context.log(\'Baobab_checkAccountingDateOpen\', \'get site for vault %s\' %(site))\n
site = context.Baobab_getVaultSite(site)\n site = context.Baobab_getVaultSite(site)\n
error = False\n accounting_date_list = context.portal_catalog(portal_type=\'Accounting Date\', site_id=site.getId(), simulation_state="opened", sort_on=[("start_date", "DESC")], limit=1)\n
if context.portal_catalog.countResults(portal_type=\'Accounting Date\', site_id=site.getId(), simulation_state="opened", limit=1)[0][0] == 0:\n if len(accounting_date_list) == 0:\n
# If there is no opened accounting date, consider today as an openned accounting day.\n opened_accounting_date = DateTime(DateTime().Date())\n
if DateTime(date) < DateTime(DateTime().Date()):\n else:\n
error = True\n opened_accounting_date = accounting_date_list[0].getStartDate()\n
elif context.portal_catalog.countResults(portal_type=\'Accounting Date\', start_date={\'query\':\'<=%s\' % (date, ), \'type\': \'date\', \'format\': \'%Y/%m/%d\'}, site_id=site.getId(), simulation_state="opened", limit=1)[0][0] == 0:\n
# If an accounting date is openned but posterior to checked date, verification fails.\n
error= True\n
\n \n
if error:\n if DateTime(date) < opened_accounting_date:\n
msg = Message(domain = "ui", message="Transaction not in the good accounting date")\n msg = Message(domain = "ui", message="Transaction date incompatible with opened accounting date ${accounting_date}.", mapping={\'accounting_date\': opened_accounting_date})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\n \n
return "ok"\n return "ok"\n
...@@ -182,9 +179,8 @@ return "ok"\n ...@@ -182,9 +179,8 @@ return "ok"\n
<string>site_list</string> <string>site_list</string>
<string>len</string> <string>len</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>False</string> <string>accounting_date_list</string>
<string>error</string> <string>opened_accounting_date</string>
<string>True</string>
<string>msg</string> <string>msg</string>
</tuple> </tuple>
</value> </value>
......
315 320
\ No newline at end of file \ No newline at end of file
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