Commit 00311942 authored by Jérome Perrin's avatar Jérome Perrin

simulation: when building, edit properties in order defined on movement groups

parent 6fd3252c
......@@ -37,13 +37,7 @@ class BaseVariantMovementGroup(MovementGroup):
portal_type = 'Base Variant Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
category_list = movement.getVariationBaseCategoryList()
if category_list is None:
category_list = []
category_list.sort()
property_dict['_base_category_list'] = category_list
return property_dict
return {'_base_category_list': sorted(movement.getVariationBaseCategoryList() or [])}
def test(self, document, property_dict, **kw):
# This movement group does not affect updating.
......
......@@ -25,6 +25,7 @@
#
##############################################################################
from collections import OrderedDict
from erp5.component.document.PropertyMovementGroup import PropertyMovementGroup
class CategoryMovementGroup(PropertyMovementGroup):
......@@ -43,7 +44,7 @@ class CategoryMovementGroup(PropertyMovementGroup):
portal_type = 'Category Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
property_dict = OrderedDict()
getProperty = movement.getProperty
for prop in self.getTestedPropertyList():
list_prop = prop + '_list'
......
......@@ -38,10 +38,7 @@ class CausalityMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw):
property_dict = {}
explanation_relative_url = self._getExplanationRelativeUrl(movement)
property_dict['_explanation'] = explanation_relative_url
return property_dict
return {'_explanation': self._getExplanationRelativeUrl(movement)}
def test(self, movement, property_dict, **kw):
# we don't care the difference of explanation url when updating
......
......@@ -26,6 +26,7 @@
#
##############################################################################
from collections import OrderedDict
from erp5.component.document.MovementGroup import MovementGroup
from DateTime import DateTime
from erp5.component.module.DateUtils import atTheEndOfPeriod
......@@ -45,7 +46,7 @@ class MonthlyRangeMovementGroup(MovementGroup):
def _getPropertyDict(self, movement, **kw):
"""Gather start_date and stop_date, converge them to the end of month.
"""
property_dict = {}
property_dict = OrderedDict()
for property_name in self.getTestedPropertyList() or ('start_date', 'stop_date'):
date = movement.getProperty(property_name, None)
if date is not None:
......
......@@ -25,6 +25,7 @@
#
##############################################################################
from collections import OrderedDict
from erp5.component.document.PropertyMovementGroup import PropertyMovementGroup
from Products.ERP5Type.Utils import UpperCase
......@@ -41,7 +42,7 @@ class ParentDeliveryPropertyMovementGroup(PropertyMovementGroup):
portal_type = 'Parent Delivery Property Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
property_dict = OrderedDict()
parent_delivery = self._getParentDelivery(movement)
if parent_delivery is not None:
for prop in self.getTestedPropertyList():
......
......@@ -40,10 +40,7 @@ class ParentExplanationMovementGroup(MovementGroup):
portal_type = 'Parent Explanation Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
parent_explanation_value = movement.getParentExplanationValue()
property_dict['parent_explanation_value'] = parent_explanation_value
return property_dict
return {'parent_explanation_value': movement.getParentExplanationValue()}
def test(self, document, property_dict, **kw):
if document.getParentExplanationValue() == \
......
......@@ -26,8 +26,10 @@
#
##############################################################################
from collections import OrderedDict
from erp5.component.document.MovementGroup import MovementGroup
class PropertyMovementGroup(MovementGroup):
"""
The purpose of MovementGroup is to define how movements are grouped,
......@@ -40,7 +42,7 @@ class PropertyMovementGroup(MovementGroup):
portal_type = 'Property Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
property_dict = OrderedDict()
getProperty = movement.getProperty
for prop in self.getTestedPropertyList():
property_dict[prop] = getProperty(prop)
......
......@@ -36,7 +36,7 @@ class RequirementMovementGroup(MovementGroup):
portal_type = 'Requirement Movement Group'
def _getPropertyDict(self, movement, **kw):
return {'requirement':self._getRequirementList(movement)}
return {'requirement': self._getRequirementList(movement)}
def test(self, movement, property_dict, **kw):
# We can always update
......
......@@ -39,10 +39,7 @@ class RootAppliedRuleCausalityMovementGroup(MovementGroup):
portal_type = 'Root Applied Rule Causality Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
root_causality_value = self._getRootCausalityValue(movement)
property_dict['root_causality_value_list'] = [root_causality_value]
return property_dict
return {'root_causality_value_list': [self._getRootCausalityValue(movement)]}
def test(self, movement, property_dict, **kw):
# We can always update
......
......@@ -37,9 +37,7 @@ class TitleMovementGroup(MovementGroup):
portal_type = 'Title Movement Group'
def _getPropertyDict(self, movement, **kw):
property_dict = {}
property_dict['title'] = self._getTitle(movement)
return property_dict
return {'title': self._getTitle(movement)}
def test(self, document, property_dict, **kw):
# If title is different, we want to update existing document instead
......
......@@ -331,8 +331,6 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# 'variation_category' or 'variation_property' pseudo properties,
# which rely on the resource being set to discover which
# categories/properties to set
# XXX-Leo: in the future: using an ordered_dict would be nice,
# but this would have to be respected on Base._edit()
edit_order = []
property_dict = {'edit_order': edit_order}
for d in property_dict_list:
......
......@@ -28,11 +28,10 @@
#
##############################################################################
from collections import OrderedDict
from warnings import warn
from Products.PythonScripts.Utility import allow_class
class FakeMovementError(Exception) : pass
class MovementGroupError(Exception) : pass
class MovementGroupNode:
# XXX last_line_movement_group is a wrong name. Actually, it is
......@@ -60,7 +59,7 @@ class MovementGroupNode:
last_line_movement_group=self._last_line_movement_group,
separate_method_name_list=self._separate_method_name_list,
merge_delivery=self._merge_delivery)
nested_instance.setGroupEdit(**property_dict)
nested_instance.setGroupEdit(property_dict)
split_movement_list = nested_instance.append(movement_list)
self._group_list.append(nested_instance)
return split_movement_list
......@@ -93,27 +92,20 @@ class MovementGroupNode:
def getGroupList(self):
return self._group_list
def setGroupEdit(self, **kw):
def setGroupEdit(self, kw):
"""
Store properties for the futur created object
Store properties for the future created object
"""
self._property_dict = kw
def updateGroupEdit(self, **kw):
"""
Update properties for the futur created object
"""
self._property_dict.update(kw)
def getGroupEditDict(self):
"""
Get property dict for the futur created object
Get property dict for the future created object
"""
property_dict = getattr(self, '_property_dict', {}).copy()
for key in property_dict.keys():
if key.startswith('_'):
del(property_dict[key])
return property_dict
return OrderedDict([
(k, v)
for (k, v) in getattr(self, '_property_dict', {}).items()
if not k.startswith('_')])
def getCurrentMovementGroup(self):
return self._movement_group
......
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