Commit ee29424c authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

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 24e68784
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
import zope.interface import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Item import Item from Products.ERP5.Document.Item import Item
from Products.ERP5.mixin.composition import CompositionMixin from Products.ERP5.mixin.composition import CompositionMixin
...@@ -112,19 +113,24 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -112,19 +113,24 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
""" """
from Products.ERP5Type.Document import newTempMovement from Products.ERP5Type.Document import newTempMovement
result = [] result = []
catalog_tool = getToolByName(self, 'portal_catalog')
# Try to find the source open order # Try to find the source open order
open_order_movement_list = self.getAggregateRelatedValueList( for movement in catalog_tool(portal_type="Open Sale Order Line",
portal_type="Open Sale Order Line") # XXX-JPS Hard Coded default_aggregate_uid=self.getUid(),
if not open_order_movement_list: validation_state=('open', 'validated', 'archived'), # XXX-JPS hard coding
return result sort_on=(('effective_date', 'descending'),
# Do not return archived if effective dates are identical
# Now generate movements for each valid open order ('validation_state', 'descending')),
for movement in open_order_movement_list: # YXU-Why we have a list here? limit=1 # Note Luke: Support the newest Open Order which defines
if movement.getParentValue().getValidationState() in ('open', 'validated'): # XXX-JPS hard coding # something for current subscription item
): # YXU-Why we have a list here?
resource = movement.getResource() resource = movement.getResource()
start_date = movement.getStartDate() start_date = movement.getStartDate()
stop_date = movement.getStopDate() 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 = movement.getSource()
source_section = movement.getSourceSection() source_section = movement.getSourceSection()
source_decision = movement.getSourceDecision() source_decision = movement.getSourceDecision()
...@@ -144,8 +150,6 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin, ...@@ -144,8 +150,6 @@ class SubscriptionItem(Item, CompositionMixin, MovementGeneratorMixin,
id_index = 0 id_index = 0
while current_date < stop_date: while current_date < stop_date:
next_date = self.getNextPeriodicalDate(current_date) next_date = self.getNextPeriodicalDate(current_date)
if next_date > stop_date:
next_date = stop_date
generated_movement = newTempMovement(self, 'subscription_%s' % id_index) generated_movement = newTempMovement(self, 'subscription_%s' % id_index)
generated_movement._edit( aggregate_value=self, generated_movement._edit( aggregate_value=self,
resource=resource, resource=resource,
......
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