Commit a6ceb0bf authored by Aurel's avatar Aurel

when checking ofr the number of account or the existence of the same...

when checking ofr the number of account or the existence of the same reference, do not take into account the current bank account on which the check is performed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27551 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aaf73895
...@@ -80,7 +80,7 @@ if bank_account.getParentValue().getPortalType()== \'Person\':\n ...@@ -80,7 +80,7 @@ if bank_account.getParentValue().getPortalType()== \'Person\':\n
# Can\'t have two bank account\n # Can\'t have two bank account\n
for obj in bank_account.getParentValue().objectValues():\n for obj in bank_account.getParentValue().objectValues():\n
if obj.getPortalType() == "Bank Account" and obj.getValidationState() not in (\'draft\', \'closed\') \\\n if obj.getPortalType() == "Bank Account" and obj.getValidationState() not in (\'draft\', \'closed\') \\\n
and obj.getSource() == bank_account.getSource():\n and obj.getSource() == bank_account.getSource() and obj.getPath()!= bank_account.getPath():\n
raise ValidationFailed, "You cannot open two bank accounts for the same person on the same site"\n raise ValidationFailed, "You cannot open two bank accounts for the same person on the same site"\n
\n \n
valid_state = ["valid", "being_closed", "validating_closing",\n valid_state = ["valid", "being_closed", "validating_closing",\n
...@@ -90,18 +90,22 @@ valid_state = ["valid", "being_closed", "validating_closing",\n ...@@ -90,18 +90,22 @@ valid_state = ["valid", "being_closed", "validating_closing",\n
same_ref_list = context.portal_catalog(validation_state=valid_state,\n same_ref_list = context.portal_catalog(validation_state=valid_state,\n
portal_type="Bank Account",\n portal_type="Bank Account",\n
reference=bank_account.getReference())\n reference=bank_account.getReference())\n
for doc in same_ref_list:\n
if doc.getPath() != bank_account.getPath():\n
context.log("doc path %s" %(doc.getPath(),))\n
raise ValidationFailed, "Bank account with same reference already exists"\n
\n \n
if len(same_ref_list):\n
raise ValidationFailed, "Bank account with same reference already exists"\n
\n \n
# Same for internal reference if exists\n # Same for internal reference if exists\n
if bank_account.getInternalBankAccountNumber() not in ("", None):\n if bank_account.getInternalBankAccountNumber() not in ("", None):\n
same_ref_list = context.portal_catalog(validation_state=valid_state,\n same_ref_list = context.portal_catalog(validation_state=valid_state,\n
portal_type="Bank Account",\n portal_type="Bank Account",\n
string_index=bank_account.getInternalBankAccountNumber())\n string_index=bank_account.getInternalBankAccountNumber())\n
\n \n
if len(same_ref_list):\n for doc in same_ref_list:\n
raise ValidationFailed, "Bank account with same internal reference already exists"\n if doc.getPath() != bank_account.getPath():\n
context.log("doc path %s" %(doc.getPath(),))\n
raise ValidationFailed, "Bank account with same internal reference already exists"\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -160,6 +164,7 @@ if bank_account.getInternalBankAccountNumber() not in ("", None):\n ...@@ -160,6 +164,7 @@ if bank_account.getInternalBankAccountNumber() not in ("", None):\n
<string>valid_state</string> <string>valid_state</string>
<string>context</string> <string>context</string>
<string>same_ref_list</string> <string>same_ref_list</string>
<string>doc</string>
<string>None</string> <string>None</string>
</tuple> </tuple>
</value> </value>
......
481 483
\ 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