diff --git a/product/ERP5/Document/OpenOrder.py b/product/ERP5/Document/OpenOrder.py index 063528db4ca6b6d7ca007122d71ae8259ca72acd..06e34c7e33cd9ddcfc344c5e6df6caebd78ec198 100644 --- a/product/ERP5/Document/OpenOrder.py +++ b/product/ERP5/Document/OpenOrder.py @@ -31,21 +31,15 @@ import zope.interface from AccessControl import ClassSecurityInfo from Products.ERP5Type import Permissions, PropertySheet, interfaces -from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5.Document.Supply import Supply -from Products.ERP5.Document.Order import Order -class OpenOrder(Supply, Order): +class OpenOrder(Supply): """ An OpenOrder is a collection of Open Order Lines - TODO: - - make sure that this should be (or not) a subclass - of Order """ meta_type = 'ERP5 Open Order' portal_type = 'Open Order' - isPredicate = ConstantGetter('isPredicate', value=True) # XXX - Why ? # Declarative security security = ClassSecurityInfo() @@ -84,4 +78,4 @@ class OpenOrder(Supply, Order): since only used by one client and tiolive. For tiolive it will be dropped out """ - \ No newline at end of file + diff --git a/product/ERP5/Document/OpenOrderCell.py b/product/ERP5/Document/OpenOrderCell.py index 4e1e9522b80a5f159ad7f4797c2d69d5b1e15e65..6a3fcec3a5b8c0717269b045aaa2794248a76942 100644 --- a/product/ERP5/Document/OpenOrderCell.py +++ b/product/ERP5/Document/OpenOrderCell.py @@ -29,16 +29,11 @@ from AccessControl import ClassSecurityInfo from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5.Document.SupplyCell import SupplyCell -from Products.ERP5.Document.OrderCell import OrderCell -class OpenOrderCell(SupplyCell, OrderCell): +class OpenOrderCell(SupplyCell): """ - A OpenOrderCell allows to define specific quantities + An Open Order Cell allows to define specific properties for each variation of a resource in an Open Order Line. - - TODO: - - make sure that this should be (or not) a subclass - of OrderCell """ meta_type = 'ERP5 Open Order Cell' portal_type = 'Open Order Cell' @@ -64,3 +59,10 @@ class OpenOrderCell(SupplyCell, OrderCell): , PropertySheet.Reference ) + def getTotalPrice(self): + """Returns the total price for this open order cell. + Unlike Amount, we do not calculate a price implicitly if not defined. + Actually, I (jerome) think amount behaviour itself if wrong. + """ + return (self.getQuantity() or 0) * (self.getPrice() or 0) + diff --git a/product/ERP5/Document/OpenOrderLine.py b/product/ERP5/Document/OpenOrderLine.py index da93d26ce0c9e3ecfc4ddf614fe57b77c69f5fdb..12b0937d2be6f9ed1df7d8295036fcdcb6a85ab3 100644 --- a/product/ERP5/Document/OpenOrderLine.py +++ b/product/ERP5/Document/OpenOrderLine.py @@ -30,16 +30,12 @@ from AccessControl import ClassSecurityInfo from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5.Document.SupplyLine import SupplyLine -from Products.ERP5.Document.OrderLine import OrderLine -class OpenOrderLine(SupplyLine, OrderLine): +class OpenOrderLine(SupplyLine): """ An Open Order Line is a Supply Line with additional properties to define repeatability - TODO: - - make sure that this should be (or not) a subclass - of OrderLine """ meta_type = 'ERP5 Open Order Line' portal_type = 'Open Order Line' @@ -66,3 +62,24 @@ class OpenOrderLine(SupplyLine, OrderLine): , PropertySheet.Comment ) + def getTotalQuantity(self, default=0): + """Returns the total quantity for this open order line. + If the order line contains cells, the total quantity of cells are + returned. + """ + if self.hasCellContent(base_id='path'): + return sum([cell.getQuantity() for cell in + self.getCellValueList(base_id='path')]) + return self.getQuantity(default) + + def getTotalPrice(self): + """Returns the total price for this open order line. + If the order line contains cells, the total price of cells are + returned. + """ + if self.hasCellContent(base_id='path'): + return sum([cell.getTotalPrice() for cell in + self.getCellValueList(base_id='path')]) + return SupplyLine.getTotalPrice(self) + +