Commit 61902d55 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

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

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