From ac7e284713fd89c0452372fd495aa1109effcc3d Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Fri, 10 Jun 2005 13:25:37 +0000
Subject: [PATCH] Initial import. Move from Business Template
 erp5_apparel_depend.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3234 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Consumption.py          | 147 ++++++++++++++++++
 product/ERP5/Document/VariationImage.py       |  55 +++++++
 .../PropertySheet/IndustrialDescription.py    |  45 ++++++
 3 files changed, 247 insertions(+)
 create mode 100755 product/ERP5/Document/Consumption.py
 create mode 100755 product/ERP5/Document/VariationImage.py
 create mode 100755 product/ERP5/PropertySheet/IndustrialDescription.py

diff --git a/product/ERP5/Document/Consumption.py b/product/ERP5/Document/Consumption.py
new file mode 100755
index 0000000000..73a9206ad5
--- /dev/null
+++ b/product/ERP5/Document/Consumption.py
@@ -0,0 +1,147 @@
+##############################################################################
+#
+# Copyright (c) 2002 Coramy SAS and Contributors. All Rights Reserved.
+#                    Thierry_Faucher <Thierry_Faucher@coramy.com>
+# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Courteaud_Romain <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
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from Globals import InitializeClass, PersistentMapping
+from AccessControl import ClassSecurityInfo
+
+from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
+from Products.ERP5Type.XMLObject import XMLObject
+from Products.ERP5Type.XMLMatrix import XMLMatrix
+from Products.ERP5.Document.Domain import Domain
+from Products.ERP5.Variated import Variated
+
+from zLOG import LOG
+
+class Consumption(XMLObject, XMLMatrix, Variated):
+    """
+      A matrix which provides default quantities
+      for a given quantity
+    """
+
+    meta_type = 'ERP5 Consumption'
+    portal_type = 'Consumption'
+
+    # Declarative security
+    security = ClassSecurityInfo()
+    security.declareObjectProtected(Permissions.View)
+
+    # Declarative properties
+    property_sheets = ( PropertySheet.Base
+                      , PropertySheet.XMLObject
+                      , PropertySheet.CategoryCore
+                      , PropertySheet.DublinCore
+                      , PropertySheet.VariationRange
+#                      , PropertySheet.Consumption
+                      )
+
+    security.declareProtected(Permissions.ModifyPortalContent, '_setMatrixCellRange')
+    def _setMatrixCellRange(self):
+      """
+        Set consumption matrix set range
+      """
+      lines, columns, tab = self.Consumption_asCellRange()
+
+      #self.setCellRange(lines, columns, base_id='quantity')
+      self.setCellRange(lines, base_id='quantity')
+
+    security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList')
+    def _setVariationCategoryList(self,value):
+      """
+        Set consumption variation category list.
+        Set matrix cell range.
+      """
+      self._setCategoryMembership(self.getVariationRangeBaseCategoryList(),value,base=1)
+      # XXX Must use in futur this method, but it failed today 
+      #Variated._setVariationCategoryList(self, value)
+      self._setMatrixCellRange()
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'setVariationCategoryList')
+    def setVariationCategoryList(self,value):
+      """
+        Set consumption variation category list.
+        Reindex Object.
+      """
+      self._setVariationCategoryList(value)
+      self.reindexObject()
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeBaseCategoryList')
+    def getVariationRangeBaseCategoryList(self):
+      """
+        Return range of base variation 
+      """
+      return self.getPortalVariationBaseCategoryList()
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeBaseCategoryItemList')
+    def getVariationRangeBaseCategoryItemList(self):
+      """
+        Return range of base variation item
+        Left display
+      """
+      # XXX get TitleOrId
+      return map( lambda x: (x,x)  , self.getVariationRangeBaseCategoryList() )
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeCategoryList')
+    def getVariationRangeCategoryList(self):
+      """
+        Return range of variation 
+      """
+      result = self.portal_categories.getCategoryChildList(self.getVariationBaseCategoryList(), base=0)
+      return result
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'getVariationRangeCategoryItemList')
+    def getVariationRangeCategoryItemList(self):
+      """
+        Return range of variation item
+      """
+      # We need a left display for ListField, and self.portal_categories.getCategoryChildTitleItemList return a right display
+      # So, invert all tuples
+      result = map( lambda x: (x[1],x[0]), self.portal_categories.getCategoryChildTitleItemList(self.getVariationBaseCategoryList(), base=1) )
+      return result
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'getQuantityRatio')
+    def getQuantityRatio(self, variation_category_line, variation_category_column):
+      """
+        Return quantity ratio for a virtual cell.
+        Return None if not result can be return.
+      """
+      cell_quantity_ratio_list = []
+      
+      for variation_category in (variation_category_line, variation_category_column):
+        cell = self.getCell(variation_category, base_id='quantity')
+        if cell is None:
+          return None
+        else:
+          cell_quantity_ratio = cell.getProperty('quantity')
+          if cell_quantity_ratio in [None, 0, '']:
+            return None
+          else:
+            cell_quantity_ratio_list.append( cell_quantity_ratio )
+
+      return cell_quantity_ratio_list[1] / cell_quantity_ratio_list[0]
diff --git a/product/ERP5/Document/VariationImage.py b/product/ERP5/Document/VariationImage.py
new file mode 100755
index 0000000000..b21712ac83
--- /dev/null
+++ b/product/ERP5/Document/VariationImage.py
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2002-2004 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Jean-Paul Smets-Solanes <jp@nexedi.com>
+#                    Courteaud_Romain <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
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from AccessControl import ClassSecurityInfo
+
+from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
+from Products.ERP5.Document.Variation import Variation
+from Products.ERP5.Document.Image import Image
+
+class VariationImage(Image, Variation):
+    """
+      A Variation combinated with a image
+    """
+
+    meta_type = 'ERP5 Variation Image'
+    portal_type = 'Variation Image'
+
+    # Declarative security
+    security = ClassSecurityInfo()
+    security.declareObjectProtected(Permissions.View)
+
+    # Declarative properties
+    property_sheets = ( PropertySheet.Base
+                      , PropertySheet.CategoryCore
+                      , PropertySheet.DublinCore
+                      , PropertySheet.Price
+                      , PropertySheet.Variation
+                      , PropertySheet.VariationRange
+    )
diff --git a/product/ERP5/PropertySheet/IndustrialDescription.py b/product/ERP5/PropertySheet/IndustrialDescription.py
new file mode 100755
index 0000000000..d6982c7903
--- /dev/null
+++ b/product/ERP5/PropertySheet/IndustrialDescription.py
@@ -0,0 +1,45 @@
+##############################################################################
+#
+# Copyright (c) 2002 Coramy SAS and Contributors. All Rights Reserved.
+# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved.
+#	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
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+class IndustrialDescription:
+  """
+  	Help for the creation
+  """
+
+  _properties = (
+        {   'id'          : 'bill_of_material_description', #XXX
+            'description' : 'A description text of the components and their consumptions in the product',
+            'type'        : 'text',
+            'mode'        : 'w' },
+        {   'id'          : 'industrial_process_description', #XXXX
+            'description' : 'A description text of operations required to build the product',
+            'type'        : 'text',
+            'mode'        : 'w' },
+      )
+
-- 
2.30.9