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 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># first get the source of the document,\n
# we will need to add the counter\n
source = context.getSource()\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
<value> <string>user_id = context.Base_getLastUserIdByTransition(workflow_id=\'check_payment_workflow\', transition_id=\'deliver_action\')\n
if user_id is None:\n
return None\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
site_value = context.portal_categories.getCategoryValue(site)\n
context.log(\'site\', site)\n
if site_value.getVaultType().endswith(\'guichet\') and source in site:\n
baobab_source = site + \'/encaisse_des_billets_et_monnaies/sortante\'\n
break\n
context.log(\'baobab_source\', baobab_source)\n
\n
\n
context.log(\'baobab_source\', baobab_source)\n
return baobab_source\n
return site + \'/encaisse_des_billets_et_monnaies/sortante\'\n
return None\n
</string> </value>
</item>
<item>
......@@ -145,13 +129,11 @@ return baobab_source\n
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>source</string>
<string>None</string>
<string>baobab_source</string>
<string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</string>
<string>None</string>
<string>site_list</string>
<string>source</string>
<string>_getiter_</string>
<string>site</string>
<string>site_value</string>
</tuple>
......
......@@ -69,29 +69,17 @@
<item>
<key> <string>_body</string> </key>
<value> <string>source = context.getSource()\n
if source != None:\n
if source is not None:\n
return source\n
else:\n
# calculate the source\n
user_site = None\n
# must use owner to know site letter\n
group_list = context.get_local_roles()\n
for group, role_list in group_list:\n
if \'Owner\' in role_list:\n
user_id = group\n
\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
# calculate the source\n
# must use owner to know site letter\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=context.Base_getOwnerId())\n
for site in site_list:\n
if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\'):\n
return site + \'/encaisse_des_billets_et_monnaies\'\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
</string> </value>
</item>
<item>
......@@ -146,15 +134,9 @@ else:\n
<string>context</string>
<string>source</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>_getiter_</string>
<string>site</string>
<string>site_value</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>message</string>
......
112
\ No newline at end of file
114
\ 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