From 32efad16e250f14902c84125c47756fde65daac2 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Fri, 12 Feb 2010 00:32:38 +0000
Subject: [PATCH] override getExpandablePropertyList() instead of
 _getExpandablePropertyDict() to provide the default value.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32452 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/DeliveryRule.py | 70 ++++++++++-----------------
 product/ERP5/Document/OrderRule.py    | 53 ++++++++------------
 2 files changed, 46 insertions(+), 77 deletions(-)

diff --git a/product/ERP5/Document/DeliveryRule.py b/product/ERP5/Document/DeliveryRule.py
index 96c39d5952..54e8dc3018 100644
--- a/product/ERP5/Document/DeliveryRule.py
+++ b/product/ERP5/Document/DeliveryRule.py
@@ -200,63 +200,43 @@ class DeliveryRule(Rule):
       return 0
     return 1
 
-  def _getExpandablePropertyDict(self, applied_rule, movement,
-      business_path=None, **kw):
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getExpandablePropertyList')
+  def getExpandablePropertyList(self, default=None):
     """
-    Return a Dictionary with the Properties used to edit
-    the simulation movement
+    Return a list of properties used in expand.
     """
-    if self._isBPM():
-      return Rule._getExpandablePropertyDict(self, applied_rule,
-          movement, business_path, **kw)
-    property_dict = {}
-
-    default_property_list = self.getExpandablePropertyList()
+    property_list = self._baseGetExpandablePropertyList()
     # For backward compatibility, we keep for some time the list
     # of hardcoded properties. Theses properties should now be
     # defined on the rule itself
-    if len(default_property_list) == 0:
-      LOG("Delivery Rule , _getExpandablePropertyDict", WARNING,
-          "Hardcoded properties set, please define your rule correctly")
-      default_property_list = (
-        'source',
-        'source_section',
-        'source_function',
-        'source_account',
-        'source_administration',
-        'source_decision',
-        'source_project',
-        'source_payment',
+    if len(property_list) == 0:
+      LOG("Order Rule , _getExpandablePropertyDict", WARNING,
+                 "Hardcoded properties set, please define your rule correctly")
+      property_list = (
+        'aggregate_list',
+        'base_application_list',
+        'base_contribution_list',
+        'description',
         'destination',
-        'destination_section',
-        'destination_function',
         'destination_account',
-        'destination_administration',
-        'destination_decision',
-        'destination_project',
-        'destination_payment',
-        'start_date',
-        'stop_date',
-        'description',
-        'resource',
-        'variation_category_list',
-        'variation_property_dict',
-        'base_contribution_list',
-        'base_application_list',
-        'aggregate_list',
+        'destination_function',
+        'destination_section',
         'price',
         'price_currency',
         'quantity',
         'quantity_unit',
-        'incoterm',
+        'resource',
+        'source',
+        'source_account',
+        'source_function',
+        'source_section',
+        'start_date',
+        'stop_date',
+        'variation_category_list',
+        'variation_property_dict',
       )
-
-    for prop in default_property_list:
-       property_dict[prop] = movement.getProperty(prop)
-
-    if movement.hasTitle():
-      property_dict['title'] = movement.getTitle()
-    return property_dict
+    return property_list
 
   def _getInputMovementList(self, applied_rule):
     """Return list of movements from delivery"""
diff --git a/product/ERP5/Document/OrderRule.py b/product/ERP5/Document/OrderRule.py
index edcf3d6642..630bac4891 100644
--- a/product/ERP5/Document/OrderRule.py
+++ b/product/ERP5/Document/OrderRule.py
@@ -149,52 +149,41 @@ class OrderRule(DeliveryRule):
     return Rule.isDivergent(self, movement)
 
   security.declareProtected(Permissions.AccessContentsInformation,
-                            '_getExpandablePropertyDict')
-  def _getExpandablePropertyDict(self, applied_rule, movement,
-      business_path=None, **kw):
+                            'getExpandablePropertyList')
+  def getExpandablePropertyList(self, default=None):
     """
-    Return a Dictionary with the Properties used to edit 
-    the simulation movement
+    Return a list of properties used in expand.
     """
-    if self._isBPM():
-      return DeliveryRule._getExpandablePropertyDict(self, applied_rule,
-          movement, business_path, **kw)
-    property_dict = {}
-
-    default_property_list = self.getExpandablePropertyList()
+    property_list = self._baseGetExpandablePropertyList()
     # For backward compatibility, we keep for some time the list
     # of hardcoded properties. Theses properties should now be
     # defined on the rule itself
-    if len(default_property_list) == 0:
+    if len(property_list) == 0:
       LOG("Order Rule , _getExpandablePropertyDict", WARNING,
                  "Hardcoded properties set, please define your rule correctly")
-      default_property_list = (
-        'source',
-        'source_section',
-        'source_function',
-        'source_account',
+      property_list = (
+        'aggregate_list',
+        'base_contribution_list',
+        'description',
         'destination',
-        'destination_section',
-        'destination_function',
         'destination_account',
-        'start_date',
-        'stop_date',
-        'description',
-        'resource',
-        'variation_category_list',
-        'variation_property_dict',
-        'base_contribution_list',
-        'aggregate_list',
+        'destination_function',
+        'destination_section',
         'price',
         'price_currency',
         'quantity',
         'quantity_unit',
+        'resource',
+        'source',
+        'source_account',
+        'source_function',
+        'source_section',
+        'start_date',
+        'stop_date',
+        'variation_category_list',
+        'variation_property_dict',
       )
-  
-    for prop in default_property_list:
-       property_dict[prop] = movement.getProperty(prop)
-       
-    return property_dict
+    return property_list
 
   def _getInputMovementList(self, applied_rule):
     """Input movement list comes from order"""
-- 
2.30.9