Commit 70c3e5ca authored by Sebastien Robin's avatar Sebastien Robin

Added script Baobab_getAccountForSite.

Also add more information on stock on counter dates, this helps a lot when we want
to close an counter date.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12419 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c320a966
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>organisation_list = [x.getObject() for x in context.portal_catalog(portal_type=\'Organisation\', site_uid=site.getUid()) if x.getObject().getRole()==\'internal\']\n
if len(organisation_list) != 1:\n
raise ValueError, \'Must not get %d organisation for the site %s\' %(len(organisation_list),site.getTitle())\n
organisation = organisation_list[0]\n
account_list = [x for x in organisation.objectValues(portal_type=\'Bank Account\') if x.getValidationState() == \'valid\']\n
if len(account_list)!=1:\n
raise ValueError, \'Must not get %d account for the organisation %s\' %(len(account_list),organisation.getTitle())\n
return account_list[0]\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>site=None</string> </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>site</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>context</string>
<string>x</string>
<string>organisation_list</string>
<string>len</string>
<string>ValueError</string>
<string>_getitem_</string>
<string>organisation</string>
<string>account_list</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Baobab_getAccountForSite</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
if site is None:\n
if getattr(context,\'getSiteValue\',None) is not None:\n
site = context.getSiteValue()\n
if site is None:\n
root_site_url = context.Baobab_getUserAssignedRootSiteList()[0]\n
site = context.portal_categories.restrictedTraverse(root_site_url)\n
\n
resource_uid_list = [x.uid for x in context.currency_cash_module.searchFolder()]\n
\n
\n
counter_vault_list = context.Delivery_getVaultItemList(\n
user_site=0,base_site=site.getRelativeUrl(),all=1,\n
vault_type=(\'site/surface/banque_interne\',\'site/surface/gros_paiement\',\n
\'site/surface/gros_versement\',\'site/surface/operations_diverses\'))\n
counter_vault_list.extend(context.Delivery_getVaultItemList(\n
user_site=0,base_site=site.getRelativeUrl(),all=1,\n
vault_type=(\'site/surface/caisse_courante\',)))\n
total_inventory_list = []\n
for counter_vault in counter_vault_list:\n
counter_title = counter_vault[0]\n
counter_vault_url = counter_vault[1]\n
if counter_vault_url==\'\':\n
continue\n
counter_title = counter_vault[0]\n
temp_list = context.CounterModule_getVaultTransactionList(vault=counter_vault_url)\n
for temp_object in temp_list:\n
temp_object.setProperty(\'counter_title\',counter_title)\n
total_inventory_list.extend(temp_list)\n
\n
return total_inventory_list\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>site=None,**kw</string> </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>site</string>
<string>kw</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>None</string>
<string>getattr</string>
<string>context</string>
<string>_getattr_</string>
<string>_getitem_</string>
<string>root_site_url</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>resource_uid_list</string>
<string>counter_vault_list</string>
<string>total_inventory_list</string>
<string>counter_vault</string>
<string>counter_title</string>
<string>counter_vault_url</string>
<string>temp_list</string>
<string>temp_object</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Baobab_getCounterStockList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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># This script will try to guess what is the current currency\n
# for the particular vault\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
vault_list = vault.split(\'/\')\n
currency_id = None\n
# Well, this is not a nice way of doing, we should have\n
# a mapping or something instead\n
context.log(\'Baobab_getVaultCurrency vault_list\',vault_list)\n
if \'encaisse_des_devises\' in vault_list:\n
vault_currency_title = vault_list[vault_list.index(\'encaisse_des_devises\')+1]\n
for currency in context.currency_module.objectValues():\n
currency_title = currency.getTitle().replace(\' \',\'_\').lower()\n
if currency_title == vault_currency_title:\n
return currency.getRelativeUrl()\n
return context.currency_module[context.Baobab_getPortalReferenceCurrencyID()].getRelativeUrl()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>vault=None,**kw</string> </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>vault</string>
<string>kw</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>_getattr_</string>
<string>vault_list</string>
<string>None</string>
<string>currency_id</string>
<string>context</string>
<string>_getitem_</string>
<string>vault_currency_title</string>
<string>_getiter_</string>
<string>currency</string>
<string>currency_title</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Baobab_getVaultCurrency</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -73,9 +73,11 @@
else:\n
site_uid = context.getSiteUid()\n
operation_list = []\n
exception_portal_type_list = [\'Paper Money Deposit\']\n
if site_uid is not None:\n
not_closed_state_list = (\'ordered\',\'planned\',\'confirmed\',\'started\',\'stopped\')\n
portal_type_list = [x for x in context.getPortalDeliveryTypeList()]\n
portal_type_list = [x for x in context.getPortalDeliveryTypeList()\n
if x not in exception_portal_type_list]\n
document_list = context.Baobab_getRemainingOperationList(\n
site_uid=site_uid,\n
simulation_state=not_closed_state_list,\n
......@@ -156,6 +158,7 @@ return operation_list\n
<string>site_uid</string>
<string>context</string>
<string>operation_list</string>
<string>exception_portal_type_list</string>
<string>not_closed_state_list</string>
<string>append</string>
<string>$append0</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_total_price</string>
<string>listbox_total_quantity</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CounterDate_viewCounterStock</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>CounterDate_viewCounterStock</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Counter Stock</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -152,6 +152,8 @@ vault_inventory_list = context.portal_simulation.getCurrentInventoryList( node=v
\n
#context.log(\'len(vault_inventory_list:\',len(vault_inventory_list))\n
for vault_inventory in vault_inventory_list:\n
if vault_inventory.total_quantity in (0.0,0,None):\n
continue\n
#context.log(\'vault_inventory total_quantity\',vault_inventory.total_quantity)\n
#context.log(\'vault_inventory total_price\',vault_inventory.total_price)\n
resource = (vault_inventory.resource_uid, vault_inventory.variation_text or \'\')\n
......
......@@ -72,8 +72,13 @@
from Products.ERP5Type.Message import Message\n
counter_date = state_change[\'object\']\n
\n
# First, make sure there is not any counter date open for this site\n
# First make sure that the site is defined\n
site_uid = counter_date.getSiteUid()\n
if site_uid is None:\n
msg = Message(domain=\'ui\',message="Sorry, the site is not defined")\n
raise ValidationFailed (msg,)\n
\n
# Then, make sure there is not any counter date open for this site\n
counter_date_list = [x.getObject() for x in counter_date.portal_catalog(portal_type=\'Counter Date\',site_uid=site_uid,simulation_state=\'open\')]\n
for other_counter in counter_date_list:\n
if other_counter.getUid()!=counter_date.getUid():\n
......@@ -150,14 +155,14 @@ if listbox is not None:\n
<string>counter_date</string>
<string>_getattr_</string>
<string>site_uid</string>
<string>None</string>
<string>msg</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>counter_date_list</string>
<string>other_counter</string>
<string>msg</string>
<string>None</string>
<string>listbox</string>
<string>start_date</string>
<string>DateTime</string>
......
......@@ -79,6 +79,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>roles</string> </key>
<value>
......@@ -91,4 +97,23 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.Expression</string>
<string>Expression</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.getSiteUid() is not None</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
114
\ No newline at end of file
116
\ 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