Commit f915a2e0 authored by Sebastien Robin's avatar Sebastien Robin

simulation: remove concept of mirror movement

Remove broken concept of Mapping Properties that was used on legacy
simulation. We do not want to use this concept any more, any mapping
should be done by rule themself. Removing mapping properties leads
to more generic concepts and much simpler code.

With legacy simulation, in case of returned sale packing list
(in case we want to invoice in same sale invoice usual sale packing
list and returned sale packing list) :
AR (delivering_rule):
  -> SM (source/A, destination/B)
    -> AR (invoicing_rule, having mapped_property mapping
           source to destination and vice versa)
      -> SM (source/A, destination/B) builders and solvers
         where doing sm.getMappedProperty('source') which was equivalent
         to sm.getProperty('destination'), thus the mapping was done
         in live time

Now in such case, we should implement mapping directly at rule level,
and this should give:
AR (delivering_rule):
  -> SM (source/A, destination/B)
    -> AR (invoicing_rule, reversing source and destination)
      -> SM (source/B, destination/A) here we directly have properties
         we wish, no need of hacks on builders and solvers
parent 6504e6fb
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/MovementGroup_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -22,7 +22,6 @@
<item>Day Movement Group</item>
<item>Delivery Causality Assignment Movement Group</item>
<item>Invoice Movement Group</item>
<item>Mirror Movement Group</item>
<item>Monthly Range Movement Group</item>
<item>Nested Line Movement Group</item>
<item>Order Movement Group</item>
......@@ -64,7 +63,6 @@
<item>Causality Movement Group</item>
<item>Day Movement Group</item>
<item>Delivery Causality Assignment Movement Group</item>
<item>Mirror Movement Group</item>
<item>Monthly Range Movement Group</item>
<item>Nested Line Movement Group</item>
<item>Order Movement Group</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>content_icon</string> </key>
<value> <string>document_icon.gif</string> </value>
</item>
<item>
<key> <string>content_meta_type</string> </key>
<value> <string>ERP5 Mirror Movement Group</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string> The purpose of MovementGroup is to define how movements are grouped,\n
and how values are updated from simulation movements.\n
</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addMirrorMovementGroup</string> </value>
</item>
<item>
<key> <string>filter_content_types</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>movement_group</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Mirror Movement Group</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>permission</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>MirrorMovementGroup</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -49,7 +49,6 @@ Image | view
Invoice Movement Group | view
Link | view
Mapped Property | view
Mirror Movement Group | view
Monthly Range Movement Group | view
Nested Line Movement Group | view
Notification Message Module | view
......
......@@ -10,7 +10,6 @@ Delivery Builder | Causality Movement Group
Delivery Builder | Day Movement Group
Delivery Builder | Delivery Causality Assignment Movement Group
Delivery Builder | Invoice Movement Group
Delivery Builder | Mirror Movement Group
Delivery Builder | Monthly Range Movement Group
Delivery Builder | Nested Line Movement Group
Delivery Builder | Order Movement Group
......@@ -40,7 +39,6 @@ Order Builder | Causality Assignment Movement Group
Order Builder | Causality Movement Group
Order Builder | Day Movement Group
Order Builder | Delivery Causality Assignment Movement Group
Order Builder | Mirror Movement Group
Order Builder | Monthly Range Movement Group
Order Builder | Nested Line Movement Group
Order Builder | Order Movement Group
......
......@@ -29,7 +29,6 @@ Image
Invoice Movement Group
Link
Mapped Property
Mirror Movement Group
Monthly Range Movement Group
Nested Line Movement Group
Notification Message
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Mirror Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>collect_order_group/delivery</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>mirror_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Mirror Movement Group</string> </value>
</item>
<item>
<key> <string>tested_property</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>mirror_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5.Document.MovementGroup import MovementGroup
class MirrorMovementGroup(MovementGroup):
"""
For Payment Transaction, we don't care the direction:
* source:A, destination:B, quantity:+10
* source:B, destination:A, quantity:-10
The purpose of MirrorMovementGroup is to make to merge these two
simulation movements into one delivery movement. To do that, we need
to reverse the order with the help of Mapped Property document that
exists in the rule.
"""
meta_type = 'ERP5 Mirror Movement Group'
portal_type = 'Mirror Movement Group'
def _getPropertyDict(self, movement, **kw):
return {}
def test(self, document, property_dict, **kw):
return True, property_dict
def _separate(self, movement_list):
# record if mirrored or not in simulation movements.
mapping_dict = {}
if len(movement_list) == 0:
return []
for movement in movement_list:
if _isMirrored(movement):
applied_rule = movement.getParentValue()
# XXX do we need more precise way to find Mapped Property
# document for mirrored?
mapping_list = mapping_dict.setdefault(
applied_rule,
applied_rule.getSpecialiseValue().objectValues(
portal_type='Mapped Property') or [])
if len(mapping_list) > 0:
movement.setPropertyMappingValue(mapping_list[0])
return [[movement_list, {}]]
def _isMirrored(document):
# to merge A->B and B->A movements, here we determine if we need to
# reverse or not by just comparing its source_section's id and
# destination_section's id, whose result should be consistent for each
# document.
return document.getDestinationSectionId() > document.getSourceSectionId()
......@@ -47,7 +47,6 @@ import random
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.utils import newSimulationExpectedFailure
from Products.ERP5.Document.MirrorMovementGroup import _isMirrored
from Testing import ZopeTestCase
from zLOG import LOG, INFO
......
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