Commit e8032d7c authored by Romain Courteaud's avatar Romain Courteaud

Bug fix: recommit previous patch, with the appropriate correction.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3746 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 32ab7872
...@@ -76,9 +76,15 @@ class RootMovementGroup: ...@@ -76,9 +76,15 @@ class RootMovementGroup:
is_movement_in_group = 0 is_movement_in_group = 0
for group in self.getGroupList(): for group in self.getGroupList():
if group.test(movement) : if group.test(movement) :
group.append(movement) try:
is_movement_in_group = 1 group.append(movement)
break is_movement_in_group = 1
break
except "MovementRejected":
if self.__class__.__name__ == self._last_line_class_name:
pass
else:
raise "MovementRejected"
if is_movement_in_group == 0 : if is_movement_in_group == 0 :
if self._nested_class is not None: if self._nested_class is not None:
self._appendGroup(movement) self._appendGroup(movement)
...@@ -90,7 +96,10 @@ class RootMovementGroup: ...@@ -90,7 +96,10 @@ class RootMovementGroup:
# 2 movements on the same node group # 2 movements on the same node group
tmp_result = self._separate(movement) tmp_result = self._separate(movement)
self._movement_list, split_movement_list = tmp_result self._movement_list, split_movement_list = tmp_result
# XXX Do something with split_movement_list ! if split_movement_list != [None]:
# We rejected a movement, we need to put it on another line
# Or to create a new one
raise "MovementRejected"
else: else:
# No movement on this node, we can add it # No movement on this node, we can add it
self._movement_list.append(movement) self._movement_list.append(movement)
...@@ -145,9 +154,12 @@ class RootMovementGroup: ...@@ -145,9 +154,12 @@ class RootMovementGroup:
new_stored_movement,\ new_stored_movement,\
rejected_movement= method(new_stored_movement, rejected_movement= method(new_stored_movement,
added_movement=added_movement) added_movement=added_movement)
added_movement = None if rejected_movement is None:
added_movement = None
else:
break
return [new_stored_movement], [rejected_movement] return [new_stored_movement], [rejected_movement]
######################################################## ########################################################
...@@ -173,6 +185,12 @@ class RootMovementGroup: ...@@ -173,6 +185,12 @@ class RootMovementGroup:
new_movement.setPriceMethod("getAveragePrice") new_movement.setPriceMethod("getAveragePrice")
return new_movement, None return new_movement, None
def calculateSeparatePrice(self, movement, added_movement=None):
"""
Separate movement which have the same price
"""
return movement, added_movement
def calculateAddQuantity(self, movement, added_movement=None): def calculateAddQuantity(self, movement, added_movement=None):
""" """
Create a new movement with the sum of quantity Create a new movement with the sum of quantity
...@@ -445,6 +463,36 @@ class CategoryMovementGroup(RootMovementGroup): ...@@ -445,6 +463,36 @@ class CategoryMovementGroup(RootMovementGroup):
allow_class(CategoryMovementGroup) allow_class(CategoryMovementGroup)
class OptionMovementGroup(RootMovementGroup):
def __init__(self,movement,**kw):
RootMovementGroup.__init__(self, movement=movement, **kw)
option_base_category_list = movement.getPortalOptionBaseCategoryList()
self.option_category_list = movement.getVariationCategoryList(base_category_list=option_base_category_list)
#LOG('OptionMovementGroup.__init__, option_category_list',0,self.option_category_list)
if self.option_category_list is None:
self.option_category_list = []
# XXX This is very bad, but no choice today.
self.setGroupEdit(industrial_phase_list = self.option_category_list)
def test(self,movement):
# we must have the same number of categories
categories_identity = 0
option_base_category_list = movement.getPortalOptionBaseCategoryList()
movement_option_category_list = movement.getVariationCategoryList(base_category_list=option_base_category_list)
#LOG('OptionMovementGroup.test, option_category_list',0,movement_option_category_list)
if movement_option_category_list is None:
movement_option_category_list = []
if len(self.option_category_list) == len(movement_option_category_list):
categories_identity = 1
for category in movement_option_category_list:
if not category in self.option_category_list :
categories_identity = 0
break
return categories_identity
allow_class(OptionMovementGroup)
class FakeMovement: class FakeMovement:
""" """
A fake movement which simulate some methods on a movement needed A fake movement which simulate some methods on a movement needed
...@@ -651,34 +699,3 @@ class FakeMovement: ...@@ -651,34 +699,3 @@ class FakeMovement:
else: else:
raise "FakeMovementError",\ raise "FakeMovementError",\
"Could not call edit on Fakeovement with parameters: %r" % key "Could not call edit on Fakeovement with parameters: %r" % key
class OptionMovementGroup(RootMovementGroup):
def __init__(self,movement,**kw):
RootMovementGroup.__init__(self, movement=movement, **kw)
option_base_category_list = movement.getPortalOptionBaseCategoryList()
self.option_category_list = movement.getVariationCategoryList(base_category_list=option_base_category_list)
#LOG('OptionMovementGroup.__init__, option_category_list',0,self.option_category_list)
if self.option_category_list is None:
self.option_category_list = []
# XXX This is very bad, but no choice today.
self.setGroupEdit(industrial_phase_list = self.option_category_list)
def test(self,movement):
# we must have the same number of categories
categories_identity = 0
option_base_category_list = movement.getPortalOptionBaseCategoryList()
movement_option_category_list = movement.getVariationCategoryList(base_category_list=option_base_category_list)
#LOG('OptionMovementGroup.test, option_category_list',0,movement_option_category_list)
if movement_option_category_list is None:
movement_option_category_list = []
if len(self.option_category_list) == len(movement_option_category_list):
categories_identity = 1
for category in movement_option_category_list:
if not category in self.option_category_list :
categories_identity = 0
break
return categories_identity
allow_class(OptionMovementGroup)
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