Commit f7c5dd9e authored by Romain Courteaud's avatar Romain Courteaud

Builder can now use calculateSeparatePrice (useful for Invoice).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3738 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 83ac132f
......@@ -248,5 +248,6 @@ class DeliveryBuilder(OrderBuilder):
delivery,
group,
self.getDeliveryLineCollectOrderList()[1:],
{})
{},
update_requested=1)
return rejected_movement_list
......@@ -231,10 +231,9 @@ class OrderBuilder(XMLObject, Amount, Predicate):
Typically, check_list is :
[DateMovementGroup,PathMovementGroup,...]
"""
class_list = []
for class_name in self.getCollectOrderList():
class_list.append(getattr(MovementGroup, class_name))
last_line_class_name = self.getDeliveryLineCollectOrderList()[-1]
class_list = [getattr(MovementGroup, x) \
for x in self.getCollectOrderList()]
last_line_class_name = self.getDeliveryCollectOrderList()[-1]
separate_method_name_list = self.getDeliveryCellSeparateOrderList()
my_root_group = MovementGroup.RootMovementGroup(
class_list,
......@@ -343,7 +342,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
return delivery_list
def _deliveryLineGroupProcessing(self, delivery, movement_group,
collect_order_list, property_dict):
collect_order_list, property_dict,
update_requested=0):
"""
Build delivery line from a list of movement on a delivery
"""
......@@ -360,6 +360,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# one
delivery_line = None
update_existing_line = 0
if update_requested==1:
for delivery_line_to_update in delivery.contentValues(
filter={'portal_type':self.getDeliveryLinePortalType()}):
if self.testObjectProperties(delivery_line_to_update, property_dict):
......
......@@ -76,9 +76,15 @@ class RootMovementGroup:
is_movement_in_group = 0
for group in self.getGroupList():
if group.test(movement) :
try:
group.append(movement)
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 self._nested_class is not None:
self._appendGroup(movement)
......@@ -90,7 +96,10 @@ class RootMovementGroup:
# 2 movements on the same node group
tmp_result = self._separate(movement)
self._movement_list, split_movement_list = tmp_result
# XXX Do something with split_movement_list !
if split_movement_list != []:
# We rejected a movement, we need to put it on another line
# Or to create a new one
raise "MovementRejected"
else:
# No movement on this node, we can add it
self._movement_list.append(movement)
......@@ -146,7 +155,10 @@ class RootMovementGroup:
new_stored_movement,\
rejected_movement= method(new_stored_movement,
added_movement=added_movement)
if rejected_movement is None:
added_movement = None
else:
break
return [new_stored_movement], [rejected_movement]
......@@ -173,6 +185,12 @@ class RootMovementGroup:
new_movement.setPriceMethod("getAveragePrice")
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):
"""
Create a new movement with the sum of quantity
......@@ -445,6 +463,36 @@ class CategoryMovementGroup(RootMovementGroup):
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:
"""
A fake movement which simulate some methods on a movement needed
......@@ -651,34 +699,3 @@ class FakeMovement:
else:
raise "FakeMovementError",\
"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