Commit 0ba4f360 authored by Jérome Perrin's avatar Jérome Perrin

Open Orders are not Orders, Open Order Lines are not Order Lines they are simply Paths.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43690 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 756cc0e7
...@@ -31,21 +31,15 @@ import zope.interface ...@@ -31,21 +31,15 @@ import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces 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.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 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' meta_type = 'ERP5 Open Order'
portal_type = 'Open Order' portal_type = 'Open Order'
isPredicate = ConstantGetter('isPredicate', value=True) # XXX - Why ?
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
......
...@@ -29,16 +29,11 @@ ...@@ -29,16 +29,11 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.SupplyCell import SupplyCell 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. 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' meta_type = 'ERP5 Open Order Cell'
portal_type = 'Open Order Cell' portal_type = 'Open Order Cell'
...@@ -64,3 +59,10 @@ class OpenOrderCell(SupplyCell, OrderCell): ...@@ -64,3 +59,10 @@ class OpenOrderCell(SupplyCell, OrderCell):
, PropertySheet.Reference , 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)
...@@ -30,16 +30,12 @@ ...@@ -30,16 +30,12 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.SupplyLine import SupplyLine 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 An Open Order Line is a Supply Line with additional
properties to define repeatability properties to define repeatability
TODO:
- make sure that this should be (or not) a subclass
of OrderLine
""" """
meta_type = 'ERP5 Open Order Line' meta_type = 'ERP5 Open Order Line'
portal_type = 'Open Order Line' portal_type = 'Open Order Line'
...@@ -66,3 +62,24 @@ class OpenOrderLine(SupplyLine, OrderLine): ...@@ -66,3 +62,24 @@ class OpenOrderLine(SupplyLine, OrderLine):
, PropertySheet.Comment , 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment