Commit 89ea2338 authored by Alain Takoudjou's avatar Alain Takoudjou

Support multiple open order line with the same effective_date.

If 2 lines have the same effective date (catalog has a 1 second precision),
always return the validate and open first.

Commit: 02d06501

Changes applied from history:

http://git.erp5.org/gitweb/erp5.git/history/refs/heads/interaction-drop:/product/ERP5/Document/SubscriptionItem.py?js=1
parent 3db47f9b
......@@ -30,6 +30,7 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Item import Item
from Products.ERP5.mixin.composition import CompositionMixin
......@@ -112,19 +113,24 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
"""
from Products.ERP5Type.Document import newTempMovement
result = []
catalog_tool = getToolByName(self, 'portal_catalog')
# Try to find the source open order
open_order_movement_list = self.getAggregateRelatedValueList(
portal_type="Open Sale Order Line") # XXX-JPS Hard Coded
if not open_order_movement_list:
return result
# Now generate movements for each valid open order
for movement in open_order_movement_list: # YXU-Why we have a list here?
if movement.getParentValue().getValidationState() in ('open', 'validated'): # XXX-JPS hard coding
for movement in catalog_tool(portal_type="Open Sale Order Line",
default_aggregate_uid=self.getUid(),
validation_state=('open', 'validated', 'archived'), # XXX-JPS hard coding
sort_on=(('effective_date', 'descending'),
# Do not return archived if effective dates are identical
('validation_state', 'descending')),
limit=1 # Note Luke: Support the newest Open Order which defines
# something for current subscription item
): # YXU-Why we have a list here?
resource = movement.getResource()
start_date = movement.getStartDate()
stop_date = movement.getStopDate()
if start_date is None or stop_date is None or start_date>=stop_date:
# infinity nor time back machine does not exist
continue
source = movement.getSource()
source_section = movement.getSourceSection()
source_decision = movement.getSourceDecision()
......
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