From aa78b01b573ccc79ceec46e7bf4f0270f8507118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 2 Nov 2009 08:59:42 +0000 Subject: [PATCH] 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 --- .../erp5_budget/BudgetCell_asPredicate.xml | 3 + .../BudgetCell_getConsumedBudget.xml | 4 +- .../BudgetCell_getEngagedBudget.xml | 4 +- .../BudgetLine_getConsumptionSign.xml | 132 ++++++++++++++ .../BudgetLine_getEditablePropertyList.xml | 141 +++++++++++++++ .../erp5_budget/BudgetLine_view.xml | 2 + .../matrixbox_destination_credit.xml | 148 +++++++++++++++ .../matrixbox_destination_debit.xml | 148 +++++++++++++++ ...box_membership_criterion_category_list.xml | 2 +- .../BudgetLine_view/matrixbox_quantity.xml | 30 ++- .../your_total_initial_budget.xml | 10 +- .../matrixbox_quantity.xml | 2 +- .../your_total_current_budget.xml | 6 +- .../mapped_value_property_list.xml | 5 + .../BudgetLine_viewFieldLibrary/matrixbox.xml | 79 +++----- ...embership_criterion_base_category_list.xml | 9 +- .../Budget_getBudgetConsumptionReportData.xml | 6 +- .../Budget_viewBudgetConsumptionReport.xml | 2 +- .../erp5_budget/NodeBudgetVariation_view.xml | 1 + .../my_include_virtual_other_node.xml | 171 ++++++++++++++++++ .../budget_interaction_workflow.xml | 19 ++ .../interactions/setVariationCategoryList.xml | 93 ++++++++++ ...erionCategoryListFromVariationCategory.xml | 143 +++++++++++++++ bt5/erp5_budget/bt/revision | 2 +- product/ERP5/Document/BudgetCell.py | 4 +- .../ERP5/Document/CategoryBudgetVariation.py | 13 +- product/ERP5/Document/NodeBudgetVariation.py | 53 +++++- 27 files changed, 1148 insertions(+), 84 deletions(-) create mode 100644 bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getConsumptionSign.xml create mode 100644 bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getEditablePropertyList.xml create mode 100644 bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_credit.xml create mode 100644 bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_debit.xml create mode 100644 bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view/my_include_virtual_other_node.xml create mode 100644 bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/interactions/setVariationCategoryList.xml create mode 100644 bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/scripts/setMembershipCriterionCategoryListFromVariationCategory.xml diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_asPredicate.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_asPredicate.xml index 916a814e70..477e694b8a 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_asPredicate.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_asPredicate.xml @@ -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 diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getConsumedBudget.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getConsumedBudget.xml index f990512978..518d409929 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getConsumedBudget.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getConsumedBudget.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getEngagedBudget.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getEngagedBudget.xml index aa5b5dca0f..6fe021b53d 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getEngagedBudget.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetCell_getEngagedBudget.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getConsumptionSign.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getConsumptionSign.xml new file mode 100644 index 0000000000..efecadfbd7 --- /dev/null +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getConsumptionSign.xml @@ -0,0 +1,132 @@ +<?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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getEditablePropertyList.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getEditablePropertyList.xml new file mode 100644 index 0000000000..46c627df85 --- /dev/null +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_getEditablePropertyList.xml @@ -0,0 +1,141 @@ +<?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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view.xml index d5fcacc1fb..362cf48a81 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_credit.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_credit.xml new file mode 100644 index 0000000000..d0ec0333fc --- /dev/null +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_credit.xml @@ -0,0 +1,148 @@ +<?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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_debit.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_debit.xml new file mode 100644 index 0000000000..4311d73861 --- /dev/null +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_destination_debit.xml @@ -0,0 +1,148 @@ +<?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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_membership_criterion_category_list.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_membership_criterion_category_list.xml index f695c43af7..3b3f2ef39b 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_membership_criterion_category_list.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_membership_criterion_category_list.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_quantity.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_quantity.xml index 1926da9c2b..185e3cb78f 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_quantity.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/matrixbox_quantity.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/your_total_initial_budget.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/your_total_initial_budget.xml index 5c8d6cf03d..8fa6684556 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/your_total_initial_budget.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_view/your_total_initial_budget.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/matrixbox_quantity.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/matrixbox_quantity.xml index 646d2d4c6c..cceccf48c4 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/matrixbox_quantity.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/matrixbox_quantity.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/your_total_current_budget.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/your_total_current_budget.xml index 3b2ceb6f60..ba1e192fe9 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/your_total_current_budget.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewCurrentBudget/your_total_current_budget.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/mapped_value_property_list.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/mapped_value_property_list.xml index a589af11e0..d507dadb87 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/mapped_value_property_list.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/mapped_value_property_list.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/matrixbox.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/matrixbox.xml index d1163146e0..e5942e7548 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/matrixbox.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/matrixbox.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/membership_criterion_base_category_list.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/membership_criterion_base_category_list.xml index 179bc17f03..e3116044d8 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/membership_criterion_base_category_list.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/BudgetLine_viewFieldLibrary/membership_criterion_base_category_list.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_getBudgetConsumptionReportData.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_getBudgetConsumptionReportData.xml index eb1478109f..f63f2b301e 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_getBudgetConsumptionReportData.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_getBudgetConsumptionReportData.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_viewBudgetConsumptionReport.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_viewBudgetConsumptionReport.xml index c094e46191..5f805476c1 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_viewBudgetConsumptionReport.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/Budget_viewBudgetConsumptionReport.xml @@ -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> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view.xml index 8c46b32a02..f13b90cac1 100644 --- a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view.xml +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view.xml @@ -112,6 +112,7 @@ <value> <list> <string>my_aggregate_title_list</string> + <string>my_include_virtual_other_node</string> </list> </value> </item> diff --git a/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view/my_include_virtual_other_node.xml b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view/my_include_virtual_other_node.xml new file mode 100644 index 0000000000..2545507040 --- /dev/null +++ b/bt5/erp5_budget/SkinTemplateItem/portal_skins/erp5_budget/NodeBudgetVariation_view/my_include_virtual_other_node.xml @@ -0,0 +1,171 @@ +<?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> diff --git a/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow.xml b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow.xml index a5d8357c09..01bf62d900 100644 --- a/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow.xml +++ b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow.xml @@ -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> diff --git a/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/interactions/setVariationCategoryList.xml b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/interactions/setVariationCategoryList.xml new file mode 100644 index 0000000000..a9cea31d8b --- /dev/null +++ b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/interactions/setVariationCategoryList.xml @@ -0,0 +1,93 @@ +<?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> diff --git a/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/scripts/setMembershipCriterionCategoryListFromVariationCategory.xml b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/scripts/setMembershipCriterionCategoryListFromVariationCategory.xml new file mode 100644 index 0000000000..e0d1402412 --- /dev/null +++ b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_interaction_workflow/scripts/setMembershipCriterionCategoryListFromVariationCategory.xml @@ -0,0 +1,143 @@ +<?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> diff --git a/bt5/erp5_budget/bt/revision b/bt5/erp5_budget/bt/revision index 7371afb09c..b6e27607fb 100644 --- a/bt5/erp5_budget/bt/revision +++ b/bt5/erp5_budget/bt/revision @@ -1 +1 @@ -236 \ No newline at end of file +242 \ No newline at end of file diff --git a/product/ERP5/Document/BudgetCell.py b/product/ERP5/Document/BudgetCell.py index bc1f2e5ea5..7162ee64a4 100644 --- a/product/ERP5/Document/BudgetCell.py +++ b/product/ERP5/Document/BudgetCell.py @@ -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 diff --git a/product/ERP5/Document/CategoryBudgetVariation.py b/product/ERP5/Document/CategoryBudgetVariation.py index 58446e05ef..087cb6498e 100644 --- a/product/ERP5/Document/CategoryBudgetVariation.py +++ b/product/ERP5/Document/CategoryBudgetVariation.py @@ -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) diff --git a/product/ERP5/Document/NodeBudgetVariation.py b/product/ERP5/Document/NodeBudgetVariation.py index 800b8d1b97..817e8c160c 100644 --- a/product/ERP5/Document/NodeBudgetVariation.py +++ b/product/ERP5/Document/NodeBudgetVariation.py @@ -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) -- 2.30.9