Commit ead3ebf4 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorise & simplify code.

Remove logs.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13513 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a78262bf
...@@ -68,32 +68,16 @@ ...@@ -68,32 +68,16 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># first get the source of the document,\n <value> <string>user_id = context.Base_getLastUserIdByTransition(workflow_id=\'check_payment_workflow\', transition_id=\'deliver_action\')\n
# we will need to add the counter\n if user_id is None:\n
source = context.getSource()\n return None\n
baobab_source = None\n
context.log(\'baobab_source\', baobab_source)\n
# Get the history of the workflow\n
user_id=\'None\'\n
context.log(\'workflow_item_list:\',context.Base_getWorkflowHistoryItemList(\'check_payment_workflow\',display=0))\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'check_payment_workflow\',display=0):\n
context.log(\'workflow_item.getProperty(action)\',workflow_item.getProperty(\'action\'))\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n
user_id=workflow_item.getProperty(\'actor\')\n
context.log(\'user_id\',user_id)\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
context.log(\'CheckPayment_getBaobabSource site_list\',site_list)\n source = context.getSource()\n
for site in site_list:\n for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n site_value = context.portal_categories.getCategoryValue(site)\n
context.log(\'site\', site)\n
if site_value.getVaultType().endswith(\'guichet\') and source in site:\n if site_value.getVaultType().endswith(\'guichet\') and source in site:\n
baobab_source = site + \'/encaisse_des_billets_et_monnaies/sortante\'\n return site + \'/encaisse_des_billets_et_monnaies/sortante\'\n
break\n return None\n
context.log(\'baobab_source\', baobab_source)\n
\n
\n
context.log(\'baobab_source\', baobab_source)\n
return baobab_source\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -145,13 +129,11 @@ return baobab_source\n ...@@ -145,13 +129,11 @@ return baobab_source\n
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>source</string>
<string>None</string>
<string>baobab_source</string>
<string>user_id</string> <string>user_id</string>
<string>_getiter_</string> <string>None</string>
<string>workflow_item</string>
<string>site_list</string> <string>site_list</string>
<string>source</string>
<string>_getiter_</string>
<string>site</string> <string>site</string>
<string>site_value</string> <string>site_value</string>
</tuple> </tuple>
......
...@@ -69,29 +69,17 @@ ...@@ -69,29 +69,17 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>source = context.getSource()\n <value> <string>source = context.getSource()\n
if source != None:\n if source is not None:\n
return source\n return source\n
else:\n # calculate the source\n
# calculate the source\n # must use owner to know site letter\n
user_site = None\n site_list = context.Baobab_getUserAssignedSiteList(user_id=context.Base_getOwnerId())\n
# must use owner to know site letter\n for site in site_list:\n
group_list = context.get_local_roles()\n if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\'):\n
for group, role_list in group_list:\n return site + \'/encaisse_des_billets_et_monnaies\'\n
if \'Owner\' in role_list:\n from Products.ERP5Type.Message import Message\n
user_id = group\n message = Message(domain="ui", message="The owner is not assigned to the right vault.")\n
\n raise ValueError,message\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
user_site = None\n
for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n
context.log(\'site_value\',site_value)\n
if site_value.getVaultType().endswith(\'guichet\'):\n
user_site = site + \'/encaisse_des_billets_et_monnaies\'\n
if user_site is None:\n
from Products.ERP5Type.Message import Message\n
message = Message(domain="ui", message="The owner is not assigned to the right vault.")\n
raise ValueError,message\n
return user_site\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -146,15 +134,9 @@ else:\n ...@@ -146,15 +134,9 @@ else:\n
<string>context</string> <string>context</string>
<string>source</string> <string>source</string>
<string>None</string> <string>None</string>
<string>user_site</string>
<string>group_list</string>
<string>_getiter_</string>
<string>group</string>
<string>role_list</string>
<string>user_id</string>
<string>site_list</string> <string>site_list</string>
<string>_getiter_</string>
<string>site</string> <string>site</string>
<string>site_value</string>
<string>Products.ERP5Type.Message</string> <string>Products.ERP5Type.Message</string>
<string>Message</string> <string>Message</string>
<string>message</string> <string>message</string>
......
112 114
\ 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