Commit ee271744 authored by Sebastien Robin's avatar Sebastien Robin

Make CashDelivery_checkCounterInventory using activities in order that there...

Make CashDelivery_checkCounterInventory using activities in order that there is no operation being reindexed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13945 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 762f4bca
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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
account = None\n
portal = context.getPortalObject()\n
catalog = portal.portal_catalog\n
portal_type = "Bank Account"\n
\n
if reference is None:\n
message = Message(domain="ui", message="Please give a reference")\n
raise ValueError, message\n
\n
account_list = catalog(reference=reference, portal_type=portal_type)\n
if len(account_list) == 0:\n
account_list = catalog(reference="%%%s%%" % reference, portal_type=portal_type)\n
if len(account_list) == 0:\n
message = Message(domain="ui", message="No bank account have this reference")\n
raise ValueError, message\n
\n
account_list = [x.getObject() for x in account_list]\n
\n
if total_price:\n
tmp_dict = {}\n
new_list = []\n
for account in account_list:\n
quantity = account.BankAccount_getCurrentPosition()\n
tmp_dict[\'total_price\'] = quantity\n
new_list.append(account.asContext(**tmp_dict))\n
account_list = new_list\n
\n
return account_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>reference=None, total_price=0</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>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>reference</string>
<string>total_price</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>None</string>
<string>account</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>catalog</string>
<string>portal_type</string>
<string>message</string>
<string>ValueError</string>
<string>account_list</string>
<string>len</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>tmp_dict</string>
<string>new_list</string>
<string>quantity</string>
<string>_write_</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BankAccount_getReportInformationList</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>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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.Document import newTempBase\n
\n
if reference is None:\n
account_list = [context]\n
else:\n
account_list = context.BankAccount_getReportInformationList(reference=reference)\n
\n
\n
\n
# Build the common inventory dict\n
params = {}\n
if from_date is not None:\n
params[\'from_date\'] = from_date\n
if at_date is not None:\n
params[\'at_date\'] = at_date\n
\n
\n
account_dict = {}\n
for account in account_list:\n
account_dict[account.getUid()] = account\n
\n
inventory_list = context.portal_simulation.getCurrentInventoryList(\n
payment_uid = account_dict.keys()\n
, **params\n
)\n
\n
final_inventory_list = []\n
portal = account.getPortalObject()\n
i = 0\n
for inventory in inventory_list:\n
tmp_dict = {}\n
movement = portal.restrictedTraverse(inventory.path)\n
delivery = movement.getExplanationValue()\n
source_reference = delivery.getSourceReference()\n
tmp_dict[\'source_reference\'] = source_reference\n
tmp_dict[\'total_price\'] = inventory.total_price\n
tmp_dict[\'description\'] = delivery.getDescription()\n
tmp_dict[\'start_date\'] = delivery.getStartDate()\n
account = account_dict[inventory.payment_uid]\n
tmp_dict[\'reference\'] = account.getReference()\n
final_inventory_list.append(newTempBase(account, "new_%03i" % i, **tmp_dict))\n
i += 1\n
\n
\n
def sort_date(a,b):\n
result = cmp(a.reference,b.reference)\n
if result == 0:\n
result = cmp(a.start_date,b.start_date)\n
return result\n
\n
final_inventory_list.sort(sort_date)\n
\n
return final_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>from_date=None, to_date=None, at_date=None, reference=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>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>from_date</string>
<string>to_date</string>
<string>at_date</string>
<string>reference</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>None</string>
<string>context</string>
<string>account_list</string>
<string>_getattr_</string>
<string>params</string>
<string>_write_</string>
<string>account_dict</string>
<string>_getiter_</string>
<string>account</string>
<string>_apply_</string>
<string>inventory_list</string>
<string>final_inventory_list</string>
<string>portal</string>
<string>i</string>
<string>inventory</string>
<string>tmp_dict</string>
<string>movement</string>
<string>delivery</string>
<string>source_reference</string>
<string>_getitem_</string>
<string>_inplacevar_</string>
<string>sort_date</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BankAccount_getReportTransactionList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -86,7 +86,10 @@ context.log(\'source\',source)\n ...@@ -86,7 +86,10 @@ context.log(\'source\',source)\n
line_list = []\n line_list = []\n
for l in tmp_list :\n for l in tmp_list :\n
# The source can be different for every line (due to getBaobabSource approach)\n # The source can be different for every line (due to getBaobabSource approach)\n
source_counter = source or l.getBaobabSource()\n if source is None:\n
source_counter = l.getBaobabSource()\n
else:\n
source_counter = source\n
# test if resource is a currency_cash\n # test if resource is a currency_cash\n
try:\n try:\n
if (l.getResourceValue().getPortalType() in currency_cash_portal_type_list) \\\n if (l.getResourceValue().getPortalType() in currency_cash_portal_type_list) \\\n
...@@ -103,10 +106,30 @@ if len(line_list) == 0 :\n ...@@ -103,10 +106,30 @@ if len(line_list) == 0 :\n
if no_balance_check:\n if no_balance_check:\n
return 0\n return 0\n
\n \n
serialize_dict = {}\n
\n
activity_tool = context.portal_activities\n
def checkActivities(line,source_counter):\n
if activity_tool.countMessageWithTag(source_counter):\n
msg = Message(domain=\'ui\', message="There are operations pending for this vault that prevent form calculating its position. Please try again later.")\n
raise ValidationFailed, (msg,)\n
\n
\n
for line in line_list :\n for line in line_list :\n
line_resource = line.getResource()\n line_resource = line.getResource()\n
# The source can be different for every line (due to getBaobabSource approach)\n # The source can be different for every line (due to getBaobabSource approach)\n
source_counter = source or line.getBaobabSource()\n if source is None:\n
source_counter = line.getBaobabSource()\n
else:\n
source_counter = source\n
# Make sure there is no reindex with the tag of this counter\n
if not serialize_dict.has_key(source_counter):\n
serialize_dict[key] = 1\n
source_object = context.portal_categories.getCategoryValue(source_counter)\n
source_object.serialize()\n
# Reindex this line with this particular source_counter tag\n
activate_kw = {\'tag\':source_counter}\n
line.reindexObject(activate_kw=activate_kw)\n
if line.hasCellContent() :\n if line.hasCellContent() :\n
for cell in line.objectValues() :\n for cell in line.objectValues() :\n
variation_text = cell.getVariationText()\n variation_text = cell.getVariationText()\n
...@@ -201,12 +224,20 @@ return 0\n ...@@ -201,12 +224,20 @@ return 0\n
<string>line_list</string> <string>line_list</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>l</string> <string>l</string>
<string>None</string>
<string>source_counter</string> <string>source_counter</string>
<string>AttributeError</string> <string>AttributeError</string>
<string>KeyError</string> <string>KeyError</string>
<string>len</string> <string>len</string>
<string>serialize_dict</string>
<string>activity_tool</string>
<string>checkActivities</string>
<string>line</string> <string>line</string>
<string>line_resource</string> <string>line_resource</string>
<string>_write_</string>
<string>key</string>
<string>source_object</string>
<string>activate_kw</string>
<string>cell</string> <string>cell</string>
<string>variation_text</string> <string>variation_text</string>
<string>inventory_value</string> <string>inventory_value</string>
......
...@@ -235,7 +235,7 @@ for resource in resource_dict.keys():\n ...@@ -235,7 +235,7 @@ for resource in resource_dict.keys():\n
tmp_dict.update({\'date\':resource_in_vault[\'date\']})\n tmp_dict.update({\'date\':resource_in_vault[\'date\']})\n
general_total_price += resource_in_vault[\'total_price\']\n general_total_price += resource_in_vault[\'total_price\']\n
tmp_dict[\'general_total_price\'] = general_total_price\n tmp_dict[\'general_total_price\'] = general_total_price\n
total_inventory_list.append(newTempBase(context, "new_%3i" % i, **tmp_dict))\n total_inventory_list.append(newTempBase(context, "new_%03i" % i, **tmp_dict))\n
i += 1\n i += 1\n
\n \n
def sort_base_price(a,b):\n def sort_base_price(a,b):\n
...@@ -343,6 +343,7 @@ return repr([x for x in total_inventory_list])\n ...@@ -343,6 +343,7 @@ return repr([x for x in total_inventory_list])\n
<string>KeyError</string> <string>KeyError</string>
<string>general_total_price</string> <string>general_total_price</string>
<string>resource_in_vault</string> <string>resource_in_vault</string>
<string>_inplacevar_</string>
<string>sort_base_price</string> <string>sort_base_price</string>
<string>repr</string> <string>repr</string>
<string>append</string> <string>append</string>
......
181 183
\ 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