From a8823f831357341271108257c5d6e71c6270d141 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 26 May 2005 08:06:43 +0000
Subject: [PATCH] Remove _edit. updateTargetQuantityFromContainerQuantity must
 be called in a InteractionWorkflow if needed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3085 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Container.py     | 75 +++-----------------------
 product/ERP5/Document/ContainerLine.py | 74 +++----------------------
 2 files changed, 12 insertions(+), 137 deletions(-)

diff --git a/product/ERP5/Document/Container.py b/product/ERP5/Document/Container.py
index 94be0040a9..9a105542a8 100755
--- a/product/ERP5/Document/Container.py
+++ b/product/ERP5/Document/Container.py
@@ -1,7 +1,8 @@
 ##############################################################################
 #
-# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
+# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
 #                    Jean-Paul Smets-Solanes <jp@nexedi.com>
+#                    Romain Courteaud <romain@nexedi.com>
 #
 # WARNING: This program as such is intended to be used by professional
 # programmers who take the whole responsability of assessing all potential
@@ -54,9 +55,6 @@ class Container(Movement, XMLObject):
 
     meta_type = 'ERP5 Container'
     portal_type = 'Container'
-    add_permission = Permissions.AddPortalContent
-    isPortalContent = 1
-    isRADContent = 1
 
     # Declarative security
     security = ClassSecurityInfo()
@@ -81,68 +79,6 @@ class Container(Movement, XMLObject):
                       , PropertySheet.SortIndex
                       )
 
-    # Factory Type Information
-    factory_type_information = \
-      {    'id'             : portal_type
-         , 'meta_type'      : meta_type
-         , 'description'    : """\
-Une ligne tarifaire."""
-         , 'icon'           : 'order_line_icon.gif'
-         , 'product'        : 'ERP5'
-         , 'factory'        : 'addContainer'
-         , 'immediate_view' : 'container_view'
-         , 'allow_discussion'     : 1
-         , 'allowed_content_types': ('Container',
-                                      )
-         , 'filter_content_types' : 1
-         , 'global_allow'   : 1
-         , 'actions'        :
-        ( { 'id'            : 'view'
-          , 'name'          : 'View'
-          , 'category'      : 'object_view'
-          , 'action'        : 'container_view'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'list'
-          , 'name'          : 'Object Contents'
-          , 'category'      : 'object_action'
-          , 'action'        : 'folder_contents'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'print'
-          , 'name'          : 'Print'
-          , 'category'      : 'object_print'
-          , 'action'        : 'order_line_print'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'metadata'
-          , 'name'          : 'Metadata'
-          , 'category'      : 'object_view'
-          , 'action'        : 'metadata_edit'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'translate'
-          , 'name'          : 'Translate'
-          , 'category'      : 'object_action'
-          , 'action'        : 'translation_template_view'
-          , 'permissions'   : (
-              Permissions.TranslateContent, )
-          }
-        )
-      }
-
-    # Force in _edit to modify variation_base_category_list first
-    security.declarePrivate( '_edit' )
-    def _edit(self, REQUEST=None, force_update = 0, **kw):
-      # No Variations at this level
-      Movement._edit(self, REQUEST=REQUEST, force_update = force_update, **kw)
-      # Fire activity to update quantities in delivery lines
-      self.getDeliveryValue().activate().updateTargetQuantityFromContainerQuantity()
-
     security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity')
     def getQuantity(self):
       """
@@ -190,9 +126,11 @@ Une ligne tarifaire."""
           container_cell_list = list(container_line.objectValues())
           container_cell_list.sort(lambda x, y: cmp(x.getVariationText(), y.getVariationText()))
           for container_cell in container_cell_list:
-            result += "%s %s %s\n" % (container_cell.getResource(), container_cell.getTargetQuantity(), '|'.join(container_cell.getVariationText().split('\n')))
+            result += "%s %s %s\n" % (container_cell.getResource(), 
+                                      container_cell.getQuantity(), 
+                                      '|'.join(container_cell.getVariationText().split('\n')))
         else:
-          result += "%s %s\n" % (container_line.getResource(), container_line.getTargetQuantity())
+          result += "%s %s\n" % (container_line.getResource(), container_line.getQuantity())
       container_list = list(self.objectValues(spec = self.meta_type))
       container_list.sort(lambda x, y: cmp(x.getContainerText(), y.getContainerText()))
       more_result = ""
@@ -253,4 +191,3 @@ Une ligne tarifaire."""
       if len(item_uid_list): return item_uid_list
       return (self.getUid(),)
 
-                  
\ No newline at end of file
diff --git a/product/ERP5/Document/ContainerLine.py b/product/ERP5/Document/ContainerLine.py
index c4c9a7c3cd..2d4c14648e 100755
--- a/product/ERP5/Document/ContainerLine.py
+++ b/product/ERP5/Document/ContainerLine.py
@@ -1,7 +1,8 @@
 ##############################################################################
 #
-# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
+# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
 #                    Jean-Paul Smets-Solanes <jp@nexedi.com>
+#                    Romain Courteaud <romain@nexedi.com>
 #
 # WARNING: This program as such is intended to be used by professional
 # programmers who take the whole responsability of assessing all potential
@@ -48,9 +49,6 @@ class ContainerLine(DeliveryLine):
 
     meta_type = 'ERP5 Container Line'
     portal_type = 'Container Line'
-    add_permission = Permissions.AddPortalContent
-    isPortalContent = 1
-    isRADContent = 1
 
     # Declarative security
     security = ClassSecurityInfo()
@@ -72,67 +70,6 @@ class ContainerLine(DeliveryLine):
                       , PropertySheet.ItemAggregation
                       )
 
-    # Factory Type Information
-    factory_type_information = \
-      {    'id'             : portal_type
-         , 'meta_type'      : meta_type
-         , 'description'    : """\
-Une ligne tarifaire."""
-         , 'icon'           : 'order_line_icon.gif'
-         , 'product'        : 'ERP5'
-         , 'factory'        : 'addContainerLine'
-         , 'immediate_view' : 'container_line_view'
-         , 'allow_discussion'     : 1
-         , 'allowed_content_types': ('Container Cell',
-                                      )
-         , 'filter_content_types' : 1
-         , 'global_allow'   : 1
-         , 'actions'        :
-        ( { 'id'            : 'view'
-          , 'name'          : 'View'
-          , 'category'      : 'object_view'
-          , 'action'        : 'container_line_view'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'list'
-          , 'name'          : 'Object Contents'
-          , 'category'      : 'object_action'
-          , 'action'        : 'folder_contents'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'print'
-          , 'name'          : 'Print'
-          , 'category'      : 'object_print'
-          , 'action'        : 'order_line_print'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'metadata'
-          , 'name'          : 'Metadata'
-          , 'category'      : 'object_view'
-          , 'action'        : 'metadata_edit'
-          , 'permissions'   : (
-              Permissions.View, )
-          }
-        , { 'id'            : 'translate'
-          , 'name'          : 'Translate'
-          , 'category'      : 'object_action'
-          , 'action'        : 'translation_template_view'
-          , 'permissions'   : (
-              Permissions.TranslateContent, )
-          }
-        )
-      }
-
-    security.declarePrivate( '_edit' )
-    def _edit(self, REQUEST=None, force_update = 0, **kw):
-      # No Variations at this level
-      DeliveryLine._edit(self, REQUEST=REQUEST, force_update = force_update, **kw)
-      # Fire activity to update quantities in delivery lines
-      self.getDeliveryValue().activate().updateTargetQuantityFromContainerQuantity()
-
     # Cell Related
     security.declareProtected( Permissions.ModifyPortalContent, 'newCellContent' )
     def newCellContent(self, id,**kw):
@@ -169,9 +106,10 @@ Une ligne tarifaire."""
       """
         Returns the quantity if no cell or the total quantity if cells
       """
-      if not self.hasCellContent():
-        return self.getTargetQuantity()
+      base_id = 'movement'
+      if not self.hasCellContent(base_id=base_id):
+        return self.getQuantity()
       else:
         # Use MySQL
         aggregate = self.ContainerLine_zGetTotal()[0]
-        return aggregate.total_quantity
+        return aggregate.total_quantity or 0.0
-- 
2.30.9