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 @@ ...@@ -69,28 +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\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
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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -145,15 +134,9 @@ else:\n ...@@ -145,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>
......
...@@ -69,28 +69,17 @@ ...@@ -69,28 +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
old_group_list = context.get_local_roles()\n if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\'):\n
for group, role_list in old_group_list:\n return site\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
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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -145,15 +134,9 @@ else:\n ...@@ -145,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>old_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>
......
...@@ -69,28 +69,17 @@ ...@@ -69,28 +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
old_group_list = context.get_local_roles()\n if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\'):\n
for group, role_list in old_group_list:\n return site\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
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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -145,15 +134,9 @@ else:\n ...@@ -145,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>old_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>
......
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n <value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n from Products.ERP5Type.Message import Message\n
\n \n
\n
var_ressource_title = context.getResourceTitle().lower()\n var_ressource_title = context.getResourceTitle().lower()\n
var_ressource_title = var_ressource_title.replace(" ", "_")\n var_ressource_title = var_ressource_title.replace(" ", "_")\n
encaisse_devise = "/encaisse_des_devises/%s/entrante" %(var_ressource_title)\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 ...@@ -80,32 +79,18 @@ encaisse_devise = "/encaisse_des_devises/%s/entrante" %(var_ressource_title)\n
\n \n
# first get the source of the document,\n # first get the source of the document,\n
# we will need to add the counter\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 # Get the history of the workflow\n
user_id=\'None\'\n user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_purchase_workflow\', transition_id=\'deliver_action\')\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'currency_purchase_workflow\',display=0):\n if user_id is None:\n
\n return None\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n
user_id=workflow_item.getProperty(\'actor\')\n
\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
\n destination = 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
\n
if site_value.getVaultType().endswith(\'guichet\') and destination in site:\n if site_value.getVaultType().endswith(\'guichet\') and destination in site:\n
baobab_destination = site + encaisse_devise\n return site + encaisse_devise\n
found = 1\n msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
\n raise ValidationFailed, (msg,)\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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -164,16 +149,13 @@ return baobab_destination\n ...@@ -164,16 +149,13 @@ return baobab_destination\n
<string>context</string> <string>context</string>
<string>var_ressource_title</string> <string>var_ressource_title</string>
<string>encaisse_devise</string> <string>encaisse_devise</string>
<string>destination</string>
<string>None</string>
<string>baobab_destination</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>destination</string>
<string>_getiter_</string>
<string>site</string> <string>site</string>
<string>site_value</string> <string>site_value</string>
<string>found</string>
<string>msg</string> <string>msg</string>
</tuple> </tuple>
</value> </value>
......
...@@ -82,34 +82,18 @@ else:\n ...@@ -82,34 +82,18 @@ else:\n
\n \n
# first get the source of the document,\n # first get the source of the document,\n
# we will need to add the counter\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 # Get the history of the workflow\n
user_id=None\n user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_sale_workflow\', transition_id=\'deliver_action\')\n
\n if user_id is None:\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'currency_sale_workflow\',display=0):\n return None\n
\n site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n source = context.getSource()\n
user_id=workflow_item.getProperty(\'actor\')\n for site in site_list:\n
\n site_value = context.portal_categories.getCategoryValue(site)\n
if user_id is not None:\n if site_value.getVaultType().endswith(\'guichet\') and source in site:\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n return site + encaisse_devise\n
\n msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
for site in site_list:\n raise ValidationFailed, (msg,)\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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -167,15 +151,12 @@ return baobab_source\n ...@@ -167,15 +151,12 @@ return baobab_source\n
<string>None</string> <string>None</string>
<string>var_ressource_title</string> <string>var_ressource_title</string>
<string>encaisse_devise</string> <string>encaisse_devise</string>
<string>source</string>
<string>baobab_source</string>
<string>user_id</string> <string>user_id</string>
<string>_getiter_</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>
<string>found</string>
<string>msg</string> <string>msg</string>
</tuple> </tuple>
</value> </value>
......
...@@ -68,37 +68,20 @@ ...@@ -68,37 +68,20 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <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 from Products.ERP5Type.Message import Message\n
\n msg = Message(domain=\'ui\', message=\'Your user is not well assigned\')\n
destination = context.getDestination()\n raise ValidationFailed, (msg,)\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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -149,22 +132,18 @@ return baobab_destination\n ...@@ -149,22 +132,18 @@ return baobab_destination\n
<tuple> <tuple>
<string>args</string> <string>args</string>
<string>kw</string> <string>kw</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>destination</string> <string>destination</string>
<string>None</string> <string>None</string>
<string>baobab_destination</string>
<string>user_id</string> <string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</string>
<string>site_list</string> <string>site_list</string>
<string>found</string> <string>_getiter_</string>
<string>site</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> <string>msg</string>
</tuple> </tuple>
</value> </value>
......
...@@ -69,27 +69,18 @@ ...@@ -69,27 +69,18 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>destination = context.getDestination()\n <value> <string>destination = context.getDestination()\n
baobab_destination = None\n if destination is None:\n
# Get the history of the workflow\n return None\n
if destination is not None:\n user_id = context.Base_getLastUserIdByTransition(workflow_id=\'currency_purchase_workflow\', transition_id=\'deliver_action\')\n
user_id=None\n if user_id is None:\n
for workflow_item in context.Base_getWorkflowHistoryItemList(\'money_deposit_workflow\',display=0):\n return None\n
if workflow_item.getProperty(\'action\')==\'deliver_action\':\n site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n
user_id=workflow_item.getProperty(\'actor\')\n for site in site_list:\n
site_list = context.Baobab_getUserAssignedSiteList(user_id=user_id)\n if context.portal_categories.getCategoryValue(site).getVaultType().endswith(\'guichet\') and destination in site:\n
context.log(\'MoneyDeposit_getBaobabDestination, site_list\',site_list)\n return site + \'/encaisse_des_billets_et_monnaies/entrante\'\n
for site in site_list:\n from Products.ERP5Type.Message import Message\n
site_value = context.portal_categories.getCategoryValue(site)\n message = Message(domain="ui", message="The owner is not assigned to the right vault.")\n
context.log(\'MoneyDeposit_getBaobabDestination, destination\',destination)\n raise ValueError,message\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
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -144,13 +135,10 @@ return baobab_destination\n ...@@ -144,13 +135,10 @@ return baobab_destination\n
<string>context</string> <string>context</string>
<string>destination</string> <string>destination</string>
<string>None</string> <string>None</string>
<string>baobab_destination</string>
<string>user_id</string> <string>user_id</string>
<string>_getiter_</string>
<string>workflow_item</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>
......
217 220
\ 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