From 9ebab69857a4ed29a9e94c2b24f80baade62ca11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 19 Mar 2009 17:50:45 +0000
Subject: [PATCH] add interaction to update membership criterion category list
 on budget line, add membership criterion category list from budget line into
 budget cell as well add TODOs on how to do this in a better way

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26102 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...box_membership_criterion_category_list.xml |  2 +-
 .../scripts/BudgetLine_updateCellRange.xml    | 20 +++++++++++++++++++
 bt5/erp5_budget/bt/revision                   |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

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 e3d1b024db..f695c43af7 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.getResource(base=1),] # XXX make this in a script ? or interaction workflow ?</string> </value>
+            <value> <string>python: list(cell_index) + context.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/WorkflowTemplateItem/portal_workflow/budget_line_interaction_workflow/scripts/BudgetLine_updateCellRange.xml b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_line_interaction_workflow/scripts/BudgetLine_updateCellRange.xml
index 71a28a40a7..78488bc0b6 100644
--- a/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_line_interaction_workflow/scripts/BudgetLine_updateCellRange.xml
+++ b/bt5/erp5_budget/WorkflowTemplateItem/portal_workflow/budget_line_interaction_workflow/scripts/BudgetLine_updateCellRange.xml
@@ -57,6 +57,21 @@
 \n
 base_id = \'cell\'\n
 line.updateCellRange(base_id=base_id)\n
+\n
+# TODO: here we should update membership criterion category list on existing cell\n
+# and add an interaction on newCell to initialize this membership\n
+\n
+# also update membership criterion category list on line\n
+if line.getMembershipCriterionBaseCategoryList():\n
+  line.setMembershipCriterionCategoryList([])\n
+  budget_line_category_list = line.getCategoryList()\n
+  for variation in budget_line_category_list:\n
+    if not variation:\n
+      continue\n
+    base, category = variation.split(\'/\', 1)\n
+    if base in line.getMembershipCriterionBaseCategoryList():\n
+      line.setMembershipCriterionCategoryList(\n
+            [variation,] + line.getMembershipCriterionCategoryList())\n
 </string> </value>
         </item>
         <item>
@@ -98,6 +113,11 @@ line.updateCellRange(base_id=base_id)\n
                             <string>line</string>
                             <string>base_id</string>
                             <string>_getattr_</string>
+                            <string>budget_line_category_list</string>
+                            <string>_getiter_</string>
+                            <string>variation</string>
+                            <string>base</string>
+                            <string>category</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_budget/bt/revision b/bt5/erp5_budget/bt/revision
index e99fdcc524..6dd90d24d3 100644
--- a/bt5/erp5_budget/bt/revision
+++ b/bt5/erp5_budget/bt/revision
@@ -1 +1 @@
-217
\ No newline at end of file
+222
\ No newline at end of file
-- 
2.30.9