Commit f70955b6 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use requirements instead of version to lookup a check model.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36763 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e1346547
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>PORTAL_TYPE_TO_CHECK_MODEL_REFERENCE = {\n
\'Person\': \'CCOP\',\n
\'Organisation\': \'CCCO\',\n
}\n
\n
entity_portal_type = context.getParentValue().getPortalType()\n
reference = PORTAL_TYPE_TO_CHECK_MODEL_REFERENCE[entity_portal_type]\n
check_resource = context.Base_getCheckModelByReference(\n
reference=reference,\n
unique_per_account=unique_per_account,\n
)\n
return check_resource\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>unique_per_account=False</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>unique_per_account</string>
<string>PORTAL_TYPE_TO_CHECK_MODEL_REFERENCE</string>
<string>_getattr_</string>
<string>context</string>
<string>entity_portal_type</string>
<string>_getitem_</string>
<string>reference</string>
<string>check_resource</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BankAccount_getCheckModel</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -108,11 +108,11 @@ if bank_account is None:\n
# Check the check.\n
check_number = transaction.getAggregateFreeText()\n
\n
# always verify check model as the version may have changed\n
version = transaction.isUniquePerAccount() and 1 or 2\n
check_resource = bank_account.BankAccount_getCheckModel(version=version).getRelativeUrl()\n
if transaction.getAggregateResource() != check_resource:\n
transaction.edit(aggregate_resource=check_resource)\n
# bind check payment with check model\n
check_resource = bank_account.BankAccount_getCheckModel(\n
unique_per_account=transaction.isUniquePerAccount(),\n
).getRelativeUrl()\n
transaction.edit(aggregate_resource=check_resource)\n
\n
if not check_number:\n
msg = Message(domain=\'ui\', message="Check not defined.")\n
......@@ -212,10 +212,9 @@ elif error[\'error_code\'] != 0:\n
<string>price</string>
<string>bank_account</string>
<string>check_number</string>
<string>version</string>
<string>check_resource</string>
<string>context</string>
<string>check</string>
<string>context</string>
<string>error</string>
</tuple>
</value>
......
......@@ -60,8 +60,11 @@ from Products.ERP5Type.Message import Message\n
if reference is None:\n
msg = Message(domain=\'ui\', message="Check not defined.")\n
raise ValidationFailed, (msg,)\n
model_list = [x for x in context.checkbook_model_module.objectValues()\n
if x.getReference()==reference]\n
model_list = [x\n
for x in context.checkbook_model_module.objectValues()\n
if x.getReference() == reference\n
and x.isUniquePerAccount() == unique_per_account\n
]\n
model_list_len = len(model_list)\n
if model_list_len == 0:\n
msg = Message(domain=\'ui\', message="Check not defined.")\n
......@@ -82,7 +85,7 @@ return model_list[0]\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=None</string> </value>
<value> <string>reference=None, unique_per_account=False</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -102,13 +105,14 @@ return model_list[0]\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>reference</string>
<string>unique_per_account</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
......@@ -138,6 +142,7 @@ return model_list[0]\n
<value>
<tuple>
<none/>
<int>0</int>
</tuple>
</value>
</item>
......
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