diff --git a/product/ERP5/DeliverySolver/FIFO.py b/product/ERP5/Document/FIFODeliverySolver.py similarity index 71% rename from product/ERP5/DeliverySolver/FIFO.py rename to product/ERP5/Document/FIFODeliverySolver.py index a27a64dea95b1c078e89590f2c5d13c5baeddfa3..facab6a40ff29505d174af633c716f148947c65b 100644 --- a/product/ERP5/DeliverySolver/FIFO.py +++ b/product/ERP5/Document/FIFODeliverySolver.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2008-2009 Nexedi SA and Contributors. All Rights Reserved. -# Jean-Paul Smets-Solanes <jp@nexedi.com> +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsibility of assessing all potential @@ -23,38 +22,47 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################## import zope.interface -from Products.ERP5Type import interfaces -from DeliverySolver import DeliverySolver +from AccessControl import ClassSecurityInfo +from Products.ERP5Type import Permissions, PropertySheet, interfaces +from Products.ERP5Type.XMLObject import XMLObject -class FIFO(DeliverySolver): +class FIFODeliverySolver(XMLObject): """ The FIFO solver reduces delivered quantity by reducing the quantity of simulation movements from the last order. """ + meta_type = 'ERP5 FIFO Delivery Solver' + portal_type = 'FIFO Delivery Solver' + add_permission = Permissions.AddPortalContent + isIndexable = 0 # We do not want to fill the catalog with objects on which we need no reporting - # Declarative interfaces - zope.interface.implements(interfaces.IDeliverySolver) + # Declarative security + security = ClassSecurityInfo() + security.declareObjectProtected(Permissions.AccessContentsInformation) - title = 'FIFO Solver' + # Default Properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.CategoryCore + , PropertySheet.DublinCore + , PropertySheet.DeliverySolver + ) - # IDeliverySolver Implementation - def __init__(self, simulation_movement_list): - """ - Move this to mixin - """ - self.simulation_movement_list = simulation_movement_list + # Declarative interfaces + zope.interface.implements(interfaces.IDeliverySolver,) + # IDeliverySolver Implementation def getTotalQuantity(self): """ Move this to mixin """ total_quantity = 0 - for movement in self.simulation_movement_list: + for movement in self.getDeliveryValueList(): total_quantity += movement.getQuantity() return total_quantity @@ -87,7 +95,7 @@ class FIFO(DeliverySolver): """ Returns a list of simulation movement sorted from the last order. """ - simulation_movement_list = self.simulation_movement_list + simulation_movement_list = self.getDeliveryValueList() if len(simulation_movement_list) > 1: return sorted(simulation_movement_list, key=lambda x:x.getExplainationValue().getStartDate(), reverse=True) diff --git a/product/ERP5/DeliverySolver/LIFO.py b/product/ERP5/Document/LIFODeliverySolver.py similarity index 59% rename from product/ERP5/DeliverySolver/LIFO.py rename to product/ERP5/Document/LIFODeliverySolver.py index 56f10c26ba027f6bf41bb85edef0f33dcfa14f65..d22a9310cba2a5890414b5a90a0b94ab594d437c 100644 --- a/product/ERP5/DeliverySolver/LIFO.py +++ b/product/ERP5/Document/LIFODeliverySolver.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2008-2009 Nexedi SA and Contributors. All Rights Reserved. -# Jean-Paul Smets-Solanes <jp@nexedi.com> +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsibility of assessing all potential @@ -23,31 +22,45 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################## import zope.interface -from Products.ERP5Type import interfaces +from AccessControl import ClassSecurityInfo +from Products.ERP5Type import Permissions, PropertySheet, interfaces +from Products.ERP5.Document.FIFODeliverySolver import FIFODeliverySolver -from FIFO import FIFO - -class LIFO(FIFO): +class LIFODeliverySolver(FIFODeliverySolver): """ The LIFO solver reduces delivered quantity by reducing the quantity of simulation movements from the first order. """ + meta_type = 'ERP5 LIFO Delivery Solver' + portal_type = 'LIFO Delivery Solver' + add_permission = Permissions.AddPortalContent + isIndexable = 0 # We do not want to fill the catalog with objects on which we need no reporting - # Declarative interfaces - zope.interface.implements(interfaces.IDeliverySolver) + # Declarative security + security = ClassSecurityInfo() + security.declareObjectProtected(Permissions.AccessContentsInformation) - title = 'LIFO Solver' + # Default Properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.CategoryCore + , PropertySheet.DublinCore + , PropertySheet.DeliverySolver + ) + + # Declarative interfaces + zope.interface.implements(interfaces.IDeliverySolver,) def _getSimulationMovementList(self): """ Returns a list of simulation movement sorted from the first order. """ - simulation_movement_list = self.simulation_movement_list + simulation_movement_list = self.getDeliveryValueList() if len(simulation_movement_list) > 1: return sorted(simulation_movement_list, key=lambda x:x.getExplainationValue().getStartDate()) diff --git a/product/ERP5/DeliverySolver/MinPrice.py b/product/ERP5/Document/MinimisePriceDeliverySolver.py similarity index 67% rename from product/ERP5/DeliverySolver/MinPrice.py rename to product/ERP5/Document/MinimisePriceDeliverySolver.py index d15e03c605cf594600fbf49f6d098241bf46ba39..2fe687858406164ee061227718a56a08e4355686 100644 --- a/product/ERP5/DeliverySolver/MinPrice.py +++ b/product/ERP5/Document/MinimisePriceDeliverySolver.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Copyright (c) 2008-2009 Nexedi SA and Contributors. All Rights Reserved. -# Jean-Paul Smets-Solanes <jp@nexedi.com> +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsibility of assessing all potential @@ -23,25 +22,41 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################## import zope.interface -from Products.ERP5Type import interfaces +from AccessControl import ClassSecurityInfo +from Products.ERP5Type import Permissions, PropertySheet, interfaces +from Products.ERP5.Document.FIFODeliverySolver import FIFODeliverySolver -from FIFO import FIFO - -class MinPrice(FIFO): +class MinimisePriceDeliverySolver(FIFODeliverySolver): """ - The MinPrice deliver solver distributes quantity in order to minimise + The Minimise Price deliver solver distributes quantity in order to minimise price. """ - # Declarative interfaces - zope.interface.implements(interfaces.IDeliverySolver) + meta_type = 'ERP5 Minimise Price Delivery Solver' + portal_type = 'Minimise Price Delivery Solver' + add_permission = Permissions.AddPortalContent + isIndexable = 0 # We do not want to fill the catalog with objects on which we need no reporting + + # Declarative security + security = ClassSecurityInfo() + security.declareObjectProtected(Permissions.AccessContentsInformation) - title = 'MinPrice Solver' + # Default Properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.CategoryCore + , PropertySheet.DublinCore + , PropertySheet.DeliverySolver + ) + + # Declarative interfaces + zope.interface.implements(interfaces.IDeliverySolver,) + # IDeliverySolver Implementation def setTotalQuantity(self, new_quantity, activate_kw=None): """ """ @@ -73,7 +88,7 @@ class MinPrice(FIFO): """ Returns a list of simulation movement sorted from the lower price. """ - simulation_movement_list = self.simulation_movement_list + simulation_movement_list = self.getDeliveryValueList() if len(simulation_movement_list) > 1: return sorted(simulation_movement_list, key=lambda x:x.getPrice()) else: diff --git a/product/ERP5/Document/QuantitySplitSolver.py b/product/ERP5/Document/QuantitySplitSolver.py index 58e548a7f11e9ba37e4616bf806a4dfa2e9ff426..213080c9238de350f070089dd6dad9b4873047ae 100644 --- a/product/ERP5/Document/QuantitySplitSolver.py +++ b/product/ERP5/Document/QuantitySplitSolver.py @@ -73,8 +73,10 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject): []).append(simulation_movement) for movement, simulation_movement_list in delivery_dict.iteritems(): decision_quantity = movement.getQuantity() - delivery_solver = self.portal_solvers.newDeliverySolver( - configuration_dict['delivery_solver'], simulation_movement_list) + delivery_solver = self.getParentValue().newContent( + portal_type=configuration_dict['delivery_solver'], + temp_object=True) + delivery_solver.setDeliveryValueList(simulation_movement_list) # Update the quantity using delivery solver algorithm split_list = delivery_solver.setTotalQuantity(decision_quantity, activate_kw=activate_kw) diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py index c128fc2e39b78669d5d12a5af62f8f6758d80749..2a41da97a1d44c1fcd9c55934e55a07fd38610d2 100644 --- a/product/ERP5/ERP5Site.py +++ b/product/ERP5/ERP5Site.py @@ -1118,6 +1118,14 @@ class ERP5Site(FolderMixIn, CMFSite): """ return self._getPortalGroupedTypeList('target_solver') + security.declareProtected(Permissions.AccessContentsInformation, + 'getPortalTargetSolverTypeList') + def getPortalDeliverySolverTypeList(self): + """ + Return delivery solver types. + """ + return self._getPortalGroupedTypeList('delivery_solver') + security.declareProtected(Permissions.AccessContentsInformation, 'getPortalAmountGeneratorTypeList') def getPortalAmountGeneratorTypeList(self): diff --git a/product/ERP5/PropertySheet/DeliverySolver.py b/product/ERP5/PropertySheet/DeliverySolver.py new file mode 100644 index 0000000000000000000000000000000000000000..83e22fedbe51add0bf4855fd1ef7f7cb7b25f53c --- /dev/null +++ b/product/ERP5/PropertySheet/DeliverySolver.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility 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 +# guarantees 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################## + +class DeliverySolver: + _categories = ('delivery',) diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 2efe8dc22f14dda50ee3a1ae9e1fc1dd9935625b..227cd63ca7a5d25dcce00e3be849b6a73e80b86e 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -260,7 +260,7 @@ class ERP5TypeInformation(XMLObject, 'recent_document', 'my_document', 'template_document', 'crawler_index', # Solvers and simulation - 'divergence_tester', 'target_solver', + 'divergence_tester', 'target_solver', 'delivery_solver', 'amount_generator', 'amount_generator_line', 'amount_generator_cell', # Movement Group 'movement_group',