Commit 1eb16cf4 authored by Jérome Perrin's avatar Jérome Perrin

Add an actiont to update summary budget cells on a budget line, and an helper...

Add an actiont to update summary budget cells on a budget line, and an helper script to get the summary categories

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37280 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2f21c8e3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_summary_budget_cell</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Modify portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Summary Budget Cells</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/BudgetLine_viewSetQuantityOnSummaryCellListDialog</string> </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>Script_magic</string> </key>
<value> <int>3</int> </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>"""Returns a dictionnary of dependant variation categories for this budget\n
line.\n
This can be used to know if a budget cell aggregates the values from other\n
budget cells.\n
For example, the returned dictionnary can be:\n
{ \'function/f\': [\'function/f/f1\', \'function/f/f2\'],\n
\'source/account_type/asset\': [\'source/account_type/asset/cash\'], }\n
As we can see on the example, only individual categories are returned, not cell\n
coordinates.\n
"""\n
# look on the budget model to see which base categories are used for non strict\n
# membership. We will only update summaries for thoses axis\n
non_strict_base_category_set = dict()\n
budget_model = context.getParentValue().getSpecialiseValue()\n
if budget_model is not None:\n
for budget_variation in budget_model.contentValues(\n
portal_type=context.getPortalBudgetVariationTypeList()):\n
if budget_variation.isMemberOf(\'budget_variation/budget_cell\') \\\n
and budget_variation.getInventoryAxis() in (\n
\'movement\',\n
\'node_category\',\n
\'mirror_node_category\',\n
\'section_category\',\n
\'mirror_section_category\',\n
\'function_category\',\n
\'project_category\',\n
\'payment_category\',):\n
\n
non_strict_base_category_set[\n
budget_variation.getProperty(\'variation_base_category\')] = True\n
\n
def reversed(seq):\n
seq = seq[::]\n
seq.sort(reverse=True)\n
return seq\n
\n
# build a dict of dependant dimensions\n
dependant_dimensions_dict = dict()\n
for bc in non_strict_base_category_set.keys():\n
vcl = reversed(context.getVariationCategoryList(base_category_list=(bc,)))\n
for vc in vcl:\n
dependant_vc_list = [other_vc for other_vc in vcl\n
if other_vc.startswith(\'%s/\' % vc)\n
and other_vc not in dependant_dimensions_dict]\n
if dependant_vc_list:\n
dependant_dimensions_dict[vc] = dependant_vc_list\n
\n
\n
from Products.ERP5Type.Utils import cartesianProduct\n
# also add all cell coordinates in the dictionnary\n
for cell_key in cartesianProduct(context.getCellRange()):\n
for key in cell_key:\n
if key in dependant_dimensions_dict:\n
dependant_dimensions_dict[tuple(cell_key)] = [] # TODO ?\n
break\n
\n
return dependant_dimensions_dict\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>dict</string>
<string>non_strict_base_category_set</string>
<string>_getattr_</string>
<string>context</string>
<string>budget_model</string>
<string>None</string>
<string>_getiter_</string>
<string>budget_variation</string>
<string>True</string>
<string>_write_</string>
<string>reversed</string>
<string>dependant_dimensions_dict</string>
<string>bc</string>
<string>vcl</string>
<string>vc</string>
<string>append</string>
<string>$append0</string>
<string>other_vc</string>
<string>dependant_vc_list</string>
<string>Products.ERP5Type.Utils</string>
<string>cartesianProduct</string>
<string>cell_key</string>
<string>key</string>
<string>tuple</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BudgetLine_getSummaryDimensionKeyDict</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>Script_magic</string> </key>
<value> <int>3</int> </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.Utils import cartesianProduct\n
from Products.ERP5Type.Message import translateString\n
\n
updated_cell_count = 0\n
\n
dependant_dimensions_dict = context.BudgetLine_getSummaryDimensionKeyDict()\n
cell_key_list = context.getCellKeyList()\n
\n
def reversed(seq):\n
seq = seq[::]\n
seq.sort(reverse=True)\n
return seq\n
\n
# we iterate in reversed order to update the deepest cells first\n
for cell_key in reversed(cartesianProduct(context.getCellRange())):\n
for idx, dimension in enumerate(cell_key):\n
if dimension in dependant_dimensions_dict:\n
dependant_cell_list = []\n
matching_cell_key = list(cell_key)\n
for key in dependant_dimensions_dict[dimension]:\n
matching_cell_key[idx] = key\n
for other_cell_key in cell_key_list:\n
if matching_cell_key == other_cell_key:\n
cell = context.getCell(*other_cell_key)\n
if cell is not None:\n
dependant_cell_list.append(cell)\n
\n
if dependant_cell_list:\n
cell = context.getCell(*cell_key)\n
if cell is None:\n
# if summary cell does not exist, we create it.\n
cell = context.newCell(*cell_key)\n
cell.edit(\n
membership_criterion_base_category_list\n
=[bc for bc in context.getVariationBaseCategoryList() if bc not\n
in context.getMembershipCriterionBaseCategoryList()],\n
membership_criterion_category_list=cell_key,\n
mapped_value_property_list=(\'quantity\', ))\n
cell.setQuantity(sum([dependant_cell.getQuantity() for dependant_cell\n
in dependant_cell_list]))\n
updated_cell_count += 1\n
break\n
\n
return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=translateString(\n
"${updated_cell_count} budget cells updated.",\n
mapping=dict(updated_cell_count=updated_cell_count))))\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\'</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>form_id</string>
<string>Products.ERP5Type.Utils</string>
<string>cartesianProduct</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>updated_cell_count</string>
<string>_getattr_</string>
<string>context</string>
<string>dependant_dimensions_dict</string>
<string>cell_key_list</string>
<string>reversed</string>
<string>_getiter_</string>
<string>cell_key</string>
<string>enumerate</string>
<string>idx</string>
<string>dimension</string>
<string>dependant_cell_list</string>
<string>list</string>
<string>matching_cell_key</string>
<string>_getitem_</string>
<string>key</string>
<string>_write_</string>
<string>other_cell_key</string>
<string>_apply_</string>
<string>cell</string>
<string>None</string>
<string>append</string>
<string>$append0</string>
<string>bc</string>
<string>sum</string>
<string>dependant_cell</string>
<string>_inplacevar_</string>
<string>dict</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>view</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BudgetLine_setQuantityOnSummaryCellList</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="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<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>action</string> </key>
<value> <string>BudgetLine_setQuantityOnSummaryCellList</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</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>left</string>
<string>right</string>
<string>center</string>
<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/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BudgetLine_viewSetQuantityOnSummaryCellListDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>BudgetLine_viewSetQuantityOnSummaryCellListDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</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>Update Summary Budget Cells</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>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
301
\ No newline at end of file
314
\ No newline at end of file
......@@ -4,6 +4,7 @@ Budget Line | consumed_view
Budget Line | current_view
Budget Line | engaged_view
Budget Line | initial_view
Budget Line | update_summary_budget_cell
Budget Model Module | view
Budget Model | view
Budget Module | budget_group_consumption_export
......
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