Commit aa78b01b authored by Jérome Perrin's avatar Jérome Perrin

Early support of budget for incomes and budget using "all others nodes" variations.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30193 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bf43cbbe
......@@ -57,6 +57,9 @@
# ideally strict membership should be an option for each category, but this API\n
# does not exist in predicates.\n
\n
# TODO: support virtual "All other nodes"\n
\n
\n
return context.generatePredicate(\n
multimembership_criterion_base_category_list = (\'resource\',),\n
criterion_property_list = (\'start_date\', \'stop_date\'))\n
......
......@@ -66,7 +66,9 @@ if at_date:\n
kw.setdefault(\'at_date\', at_date)\n
\n
# XXX use getBudgetConsumptionMethod ?\n
return context.portal_simulation.getCurrentInventoryAssetPrice(src__=src__, **kw)\n
if src__:\n
return context.portal_simulation.getCurrentInventoryAssetPrice(src__=src__, **kw)\n
return (context.portal_simulation.getCurrentInventoryAssetPrice(**kw) or 0) * context.getParentValue().BudgetLine_getConsumptionSign()\n
</string> </value>
</item>
<item>
......
......@@ -70,7 +70,9 @@ kw.setdefault(\'explanation_simulation_state\', context.getPortalReservedInvento
+ context.getPortalTransitInventoryStateList())\n
\n
# XXX use getBudgetConsumptionMethod ?\n
return context.portal_simulation.getInventoryAssetPrice(src__=src__, **kw)\n
if src__:\n
return context.portal_simulation.getInventoryAssetPrice(src__=src__, **kw)\n
return (context.portal_simulation.getInventoryAssetPrice(**kw) or 0) * context.getParentValue().BudgetLine_getConsumptionSign()\n
</string> </value>
</item>
<item>
......
<?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>editable_property_list = zip(*context.BudgetLine_getEditablePropertyList())[0]\n
\n
if \'destination_credit\' in editable_property_list:\n
return -1\n
if \'destination_asset_credit\' in editable_property_list:\n
return -1\n
return 1\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>_getitem_</string>
<string>_apply_</string>
<string>zip</string>
<string>_getattr_</string>
<string>context</string>
<string>editable_property_list</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_getConsumptionSign</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>item_list = []\n
\n
# FIXME: it\'s not so good to use a category here ...\n
\n
if context.isMemberOf(\'budget_line_type/quantity\'):\n
item_list.append((\'quantity\', \'quantity\'))\n
if context.isMemberOf(\'budget_line_type/destination_debit\'):\n
item_list.append((\'destination_debit\', \'destination_debit\'))\n
if context.isMemberOf(\'budget_line_type/destination_credit\'):\n
item_list.append((\'destination_credit\', \'destination_credit\'))\n
\n
if not item_list:\n
# by default we use quantity\n
item_list = [(\'quantity\', \'quantity\')]\n
\n
item_list.append(\n
(\'membership_criterion_category_list\',\n
\'membership_criterion_category_list\'))\n
return item_list\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>item_list</string>
<string>_getattr_</string>
<string>context</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_getEditablePropertyList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -88,6 +88,8 @@
<list>
<string>matrixbox_membership_criterion_category_list</string>
<string>matrixbox_quantity</string>
<string>matrixbox_destination_credit</string>
<string>matrixbox_destination_debit</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>enabled</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matrixbox_destination_credit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>matrixbox_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>BudgetLine_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/getDestinationCredit | nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: \'destination_credit\' in zip(*context.BudgetLine_getEditablePropertyList())[0]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>enabled</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>matrixbox_destination_debit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>matrixbox_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>BudgetLine_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/getDestinationDebit | nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: \'destination_debit\' in zip(*context.BudgetLine_getEditablePropertyList())[0]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -115,7 +115,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: list(cell_index) + context.getMembershipCriterionCategoryList() + [context.getResource(base=1),] # XXX make this in a script ? or interaction workflow ?</string> </value>
<value> <string>python: list(cell_index) + context.getMembershipCriterionCategoryList() + context.getParentValue().getMembershipCriterionCategoryList() + [context.getResource(base=1),] # XXX make this in a script ? or interaction workflow ?</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -12,7 +12,9 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
<list>
<string>enabled</string>
</list>
</value>
</item>
<item>
......@@ -53,6 +55,12 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -72,6 +80,10 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>matrixbox_quantity</string> </value>
......@@ -90,4 +102,20 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: \'quantity\' in zip(*context.BudgetLine_getEditablePropertyList())[0]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -13,10 +13,10 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
<string>precision</string>
<string>editable</string>
<string>precision</string>
<string>title</string>
</list>
</value>
</item>
......@@ -64,6 +64,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -138,7 +142,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: sum([cell.getQuantity() for cell in context.getCellValueList()])</string> </value>
<value> <string>python: sum([cell.getQuantity() for cell in context.getCellValueList()]) * context.BudgetLine_getConsumptionSign()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -122,7 +122,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/getCurrentBalance</string> </value>
<value> <string>python: cell.getCurrentBalance() * context.BudgetLine_getConsumptionSign()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -13,10 +13,10 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>default</string>
<string>precision</string>
<string>editable</string>
<string>precision</string>
<string>title</string>
</list>
</value>
</item>
......@@ -142,7 +142,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: sum([cell.getCurrentBalance() for cell in context.getCellValueList()])</string> </value>
<value> <string>python: sum([cell.getCurrentBalance() for cell in context.getCellValueList()]) * context.BudgetLine_getConsumptionSign()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -223,6 +223,11 @@
<value>
<list>
<string>quantity</string>
<string>price</string>
<string>destination_debit</string>
<string>destination_credit</string>
<string>destination_asset_debit</string>
<string>destination_asset_credit</string>
</list>
</value>
</item>
......
......@@ -111,19 +111,25 @@
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>as_cell_range_script_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cell_base_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cell_getter_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cell_portal_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>columns</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
......@@ -143,7 +149,9 @@
</item>
<item>
<key> <string>editable_attributes</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
......@@ -167,15 +175,11 @@
</item>
<item>
<key> <string>lines</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
<item>
<key> <string>tabs</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -196,10 +200,18 @@
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>as_cell_range_script_id</string> </key>
<value> <string>BudgetLine_asCellRange</string> </value>
</item>
<item>
<key> <string>cell_base_id</string> </key>
<value> <string>cell</string> </value>
</item>
<item>
<key> <string>cell_getter_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cell_portal_type</string> </key>
<value> <string>Budget Cell</string> </value>
......@@ -301,56 +313,15 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.BudgetLine_asCellRange(matrixbox=1)[1]</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.BudgetLine_asCellRange(matrixbox=1)[0]</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.BudgetLine_asCellRange(matrixbox=1)[2]</string> </value>
<value> <string>context/BudgetLine_getEditablePropertyList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -303,18 +303,15 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/getVariationBaseCategoryList</string> </value>
<value> <string>python: context.getVariationBaseCategoryList() + context.getParentValue().getVariationBaseCategoryList() # XXX add resource ??</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -150,14 +150,15 @@ for budget in budget_list:\n
title=cell_name_dict[level_2_category])]\n
\n
for level_3_category in level_3_variation_category_list:\n
sign = budget_line.BudgetLine_getConsumptionSign()\n
for cell in budget_line.getCellValueList():\n
if not isVisibleCell(cell):\n
continue\n
if level_2_category in cell.getMembershipCriterionCategoryList() and\\\n
level_3_category in cell.getMembershipCriterionCategoryList():\n
\n
initial_budget = cell.getQuantity()\n
current_budget = cell.getCurrentBalance()\n
initial_budget = cell.getQuantity() * sign\n
current_budget = cell.getCurrentBalance() * sign\n
engaged_budget = cell.getEngagedBudget()\n
consumed_budget = cell.getConsumedBudget()\n
available_budget = cell.getAvailableBudget()\n
......@@ -316,6 +317,7 @@ return pformat(line_list)\n
<string>total_level_2_available_budget</string>
<string>level_2_line_list</string>
<string>level_3_category</string>
<string>sign</string>
<string>cell</string>
<string>initial_budget</string>
<string>current_budget</string>
......
......@@ -475,7 +475,7 @@ AQABAEMAAAB9AQAAAAA=</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
<value> <string>Budget Consumption</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -112,6 +112,7 @@
<value>
<list>
<string>my_aggregate_title_list</string>
<string>my_include_virtual_other_node</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_include_virtual_other_node</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Include a Virtual Node For "All Others"</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -15,6 +15,17 @@
<tuple/>
</value>
</item>
<item>
<key> <string>creation_guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>TODO:\r\n
changing a membership must be "recursive" (or budget line/cell membership method should dynamically read from their parent)</string> </value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
......@@ -25,6 +36,14 @@
<key> <string>id</string> </key>
<value> <string>budget_interaction_workflow</string> </value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Interaction Workflow Definition</string> </value>
</item>
</dictionary>
</pickle>
</record>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>setMembershipCriterionCategoryListFromVariationCategory</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Sets the membership critertion categories from the variation categories.</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>setVariationCategoryList</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setVariationCategoryList</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </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>budget = sci[\'object\']\n
\n
membership_criterion_category_list = budget.getMembershipCriterionCategoryList()\n
for base_category in budget.getMembershipCriterionBaseCategoryList():\n
if base_category in budget.getVariationBaseCategoryList():\n
# Remove all previous membership from the same base\n
cleaned_membership_criterion_category_list = []\n
for membership_criterion_category in membership_criterion_category_list:\n
if not membership_criterion_category.startswith("%s/" % base_category):\n
cleaned_membership_criterion_category_list.append(membership_criterion_category)\n
# Add the new one\n
membership_criterion_category_list.extend(\n
budget.getVariationCategoryList(base_category_list=base_category))\n
\n
budget.setMembershipCriterionCategoryList(membership_criterion_category_list)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>sci</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>sci</string>
<string>_getitem_</string>
<string>budget</string>
<string>_getattr_</string>
<string>membership_criterion_category_list</string>
<string>_getiter_</string>
<string>base_category</string>
<string>cleaned_membership_criterion_category_list</string>
<string>membership_criterion_category</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>setMembershipCriterionCategoryListFromVariationCategory</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
236
\ No newline at end of file
242
\ No newline at end of file
......@@ -32,9 +32,11 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5.Document.Predicate import Predicate
from Products.ERP5.Document.MetaNode import MetaNode
from Products.ERP5.Document.Movement import Movement
class BudgetCell(Predicate, MetaNode):
class BudgetCell(Predicate, MetaNode, Movement):
""" Budget Cell defines a cell of budget.
XXX This is not a Movement, but we need getDestinationCredit
"""
# Default Properties
......
......@@ -168,12 +168,19 @@ class CategoryBudgetVariation(BudgetVariation):
def initializeBudget(self, budget):
"""Initialize a budget.
"""
budget_variation_category_list =\
budget_variation_base_category_list =\
list(budget.getVariationBaseCategoryList() or [])
budget_membership_criterion_base_category_list =\
list(budget.getMembershipCriterionBaseCategoryList() or [])
base_category = self.getProperty('variation_base_category')
if base_category:
budget_variation_category_list.append(base_category)
if base_category not in budget_variation_base_category_list:
budget_variation_base_category_list.append(base_category)
if base_category not in budget_membership_criterion_base_category_list:
budget_membership_criterion_base_category_list.append(base_category)
budget.setVariationBaseCategoryList(
budget_variation_category_list)
budget_variation_base_category_list)
budget.setMembershipCriterionBaseCategoryList(
budget_membership_criterion_base_category_list)
......@@ -30,13 +30,38 @@ from AccessControl import ClassSecurityInfo
from AccessControl.ZopeGuards import guarded_getattr
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5.Document.BudgetVariation import BudgetVariation
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
from Products.ERP5Type.Message import translateString
class VirtualNode(object):
"""A Virtual Node for all Other Nodes.
This virtual document can be used in budget variations.
"""
__allow_access_to_unprotected_subobjects__ = True
def __init__(self, relative_url):
"""The Virtual Node will use the relative URL of the budget line for
memberships.
"""
self.relative_url = relative_url
def getTitle(self):
return translateString('All Others')
def getRelativeUrl(self):
return self.relative_url
def getUid(self):
return -1L
class NodeBudgetVariation(BudgetVariation):
""" A budget variation for node
A script will return the list of possible nodes, or they will be configured
explicitly on the budget variation.
explicitly on the budget variation. It is also possible to include a virtual
node for all others not selected nodes.
"""
# Default Properties
property_sheets = ( PropertySheet.Base
......@@ -72,6 +97,9 @@ class NodeBudgetVariation(BudgetVariation):
if node_select_method_id:
return guarded_getattr(context, node_select_method_id)()
# no script defined, used the explicitly selected values
if self.getProperty('include_virtual_other_node'):
return self.getAggregateValueList() + [
VirtualNode(context.getRelativeUrl()), ]
return self.getAggregateValueList()
def _getNodeTitle(self, node):
......@@ -105,6 +133,7 @@ class NodeBudgetVariation(BudgetVariation):
base_category = self.getProperty('variation_base_category')
if not base_category:
return dict()
budget_line = budget_cell.getParentValue()
for criterion_category in budget_cell.getMembershipCriterionCategoryList():
if '/' not in criterion_category: # safe ...
continue
......@@ -113,6 +142,14 @@ class NodeBudgetVariation(BudgetVariation):
if axis == 'movement':
axis = 'default_%s' % base_category
axis = '%s_uid' % axis
if node_url == budget_line.getRelativeUrl():
# This is the "All Other" virtual node
other_uid_list = []
for node in self._getNodeList(budget_line):
if '%s/%s' % (base_category, node.getRelativeUrl()) in\
budget_line.getVariationCategoryList():
other_uid_list.append(node.getUid())
return {axis: NegatedQuery(Query(**{axis: other_uid_list}))}
return {axis:
self.getPortalObject().unrestrictedTraverse(node_url).getUid()}
......@@ -161,12 +198,18 @@ class NodeBudgetVariation(BudgetVariation):
def initializeBudget(self, budget):
"""Initialize a budget.
"""
budget_variation_category_list =\
budget_variation_base_category_list =\
list(budget.getVariationBaseCategoryList() or [])
budget_membership_criterion_base_category_list =\
list(budget.getMembershipCriterionBaseCategoryList() or [])
base_category = self.getProperty('variation_base_category')
if base_category:
budget_variation_category_list.append(base_category)
if base_category not in budget_variation_base_category_list:
budget_variation_base_category_list.append(base_category)
if base_category not in budget_membership_criterion_base_category_list:
budget_membership_criterion_base_category_list.append(base_category)
budget.setVariationBaseCategoryList(
budget_variation_category_list)
budget_variation_base_category_list)
budget.setMembershipCriterionBaseCategoryList(
budget_membership_criterion_base_category_list)
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