Commit 5c101296 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorise & simplify code.

Remove logs.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13515 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 33a961e9
......@@ -69,28 +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
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\n
if 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 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\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>
......@@ -145,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>
......
......@@ -69,28 +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
old_group_list = context.get_local_roles()\n
for group, role_list in old_group_list:\n
if \'Owner\' in role_list:\n
user_id = group\n
\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\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\n
if 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 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\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>
......@@ -145,15 +134,9 @@ else:\n
<string>context</string>
<string>source</string>
<string>None</string>
<string>user_site</string>
<string>old_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>
......
......@@ -69,28 +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
old_group_list = context.get_local_roles()\n
for group, role_list in old_group_list:\n
if \'Owner\' in role_list:\n
user_id = group\n
\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\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\n
if 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 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\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>
......@@ -145,15 +134,9 @@ else:\n
<string>context</string>
<string>source</string>
<string>None</string>
<string>user_site</string>
<string>old_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>
......
......@@ -71,7 +71,6 @@
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
\n
var_ressource_title = context.getResourceTitle().lower()\n
var_ressource_title = var_ressource_title.replace(" ", "_")\n
encaisse_devise = "/encaisse_des_devises/%s/entrante" %(var_ressource_title)\n
......@@ -80,32 +79,18 @@ encaisse_devise = "/encaisse_des_devises/%s/entrante" %(var_ressource_title)\n
\n
# first get the source of the document,\n
# we will need to add the counter\n
destination = context.getSource()\n
baobab_destination = None\n
\n
# Get the history of the workflow\n
user_id=\'None\'\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'currency_purchase_workflow\',display=0):\n
\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n
user_id=workflow_item.getProperty(\'actor\')\n
\n
user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_purchase_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
\n
destination = context.getSource()\n
for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n
\n
if site_value.getVaultType().endswith(\'guichet\') and destination in site:\n
baobab_destination = site + encaisse_devise\n
found = 1\n
\n
break\n
\n
if not found:\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
\n
return baobab_destination\n
return site + encaisse_devise\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
</string> </value>
</item>
<item>
......@@ -164,16 +149,13 @@ return baobab_destination\n
<string>context</string>
<string>var_ressource_title</string>
<string>encaisse_devise</string>
<string>destination</string>
<string>None</string>
<string>baobab_destination</string>
<string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</string>
<string>None</string>
<string>site_list</string>
<string>destination</string>
<string>_getiter_</string>
<string>site</string>
<string>site_value</string>
<string>found</string>
<string>msg</string>
</tuple>
</value>
......
......@@ -82,34 +82,18 @@ else:\n
\n
# first get the source of the document,\n
# we will need to add the counter\n
source = context.getSource()\n
baobab_source = None\n
\n
# Get the history of the workflow\n
user_id=None\n
\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'currency_sale_workflow\',display=0):\n
\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n
user_id=workflow_item.getProperty(\'actor\')\n
\n
if user_id is not None:\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
\n
for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n
\n
if site_value.getVaultType().endswith(\'guichet\') and source in site:\n
baobab_source = site + encaisse_devise\n
found = 1\n
\n
break\n
\n
if not found:\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
\n
return baobab_source\n
user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_sale_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
source = context.getSource()\n
for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n
if site_value.getVaultType().endswith(\'guichet\') and source in site:\n
return site + encaisse_devise\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
</string> </value>
</item>
<item>
......@@ -167,15 +151,12 @@ return baobab_source\n
<string>None</string>
<string>var_ressource_title</string>
<string>encaisse_devise</string>
<string>source</string>
<string>baobab_source</string>
<string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</string>
<string>site_list</string>
<string>source</string>
<string>_getiter_</string>
<string>site</string>
<string>site_value</string>
<string>found</string>
<string>msg</string>
</tuple>
</value>
......
......@@ -68,37 +68,20 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
<value> <string>destination = context.getDestination()\n
if destination is None:\n
return None\n
user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_purchase_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
for site in site_list:\n
if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\') and (destination in site or site in destination):\n
return site + \'/encaisse_des_billets_et_monnaies/entrante\'\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
destination = context.getDestination()\n
context.log(\'destination\',destination)\n
baobab_destination = None\n
# Get the history of the workflow\n
user_id=None\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'internal_money_deposit_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
\n
if user_id is not None:\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
context.log(\'InternalMoneyDeposit_getBaobabDestination site_list\',site_list)\n
found = 0\n
for site in site_list:\n
context.log(\'site\',site)\n
site_value = context.portal_categories.getCategoryValue(site)\n
if site_value.getVaultType().endswith(\'guichet\') and (destination in site or site in destination):\n
baobab_destination = site + \'/encaisse_des_billets_et_monnaies/entrante\'\n
found = 1\n
context.log(\'baobab_destination\',baobab_destination)\n
break\n
\n
if not found:\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
\n
return baobab_destination\n
msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
raise ValidationFailed, (msg,)\n
</string> </value>
</item>
<item>
......@@ -149,22 +132,18 @@ return baobab_destination\n
<tuple>
<string>args</string>
<string>kw</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getattr_</string>
<string>context</string>
<string>destination</string>
<string>None</string>
<string>baobab_destination</string>
<string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</string>
<string>site_list</string>
<string>found</string>
<string>_getiter_</string>
<string>site</string>
<string>site_value</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>msg</string>
</tuple>
</value>
......
......@@ -69,27 +69,18 @@
<item>
<key> <string>_body</string> </key>
<value> <string>destination = context.getDestination()\n
baobab_destination = None\n
# Get the history of the workflow\n
if destination is not None:\n
user_id=None\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'money_deposit_workflow\',display=0):\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n
user_id=workflow_item.getProperty(\'actor\')\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
context.log(\'MoneyDeposit_getBaobabDestination, site_list\',site_list)\n
for site in site_list:\n
site_value = context.portal_categories.getCategoryValue(site)\n
context.log(\'MoneyDeposit_getBaobabDestination, destination\',destination)\n
context.log(\'MoneyDeposit_getBaobabDestination, site\',site)\n
if site_value.getVaultType().endswith(\'guichet\') and destination in site:\n
baobab_destination = site + \'/encaisse_des_billets_et_monnaies/entrante\'\n
break\n
if user_id is not None and baobab_destination 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 baobab_destination\n
if destination is None:\n
return None\n
user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_purchase_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
for site in site_list:\n
if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\') and destination in site:\n
return site + \'/encaisse_des_billets_et_monnaies/entrante\'\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>
......@@ -144,13 +135,10 @@ return baobab_destination\n
<string>context</string>
<string>destination</string>
<string>None</string>
<string>baobab_destination</string>
<string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</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>
......
217
\ No newline at end of file
220
\ 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