diff --git a/bt5/erp5_base/ActionTemplateItem/portal_types/Mirror%20Movement%20Group/view.xml b/bt5/erp5_base/ActionTemplateItem/portal_types/Mirror%20Movement%20Group/view.xml index 197525691e0eb86d68df5f1ab50ebe81d76bd1cf..5bffd3566b9c7c37cc3739916d7902b59f424a4f 100644 --- a/bt5/erp5_base/ActionTemplateItem/portal_types/Mirror%20Movement%20Group/view.xml +++ b/bt5/erp5_base/ActionTemplateItem/portal_types/Mirror%20Movement%20Group/view.xml @@ -77,7 +77,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>string:${object_url}/PropertyMovementGroup_view</string> </value> + <value> <string>string:${object_url}/MovementGroup_view</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_base/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml b/bt5/erp5_base/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml index 5127ff1f0c79aed384754a6e40cdd1c839a8c09e..d37974ec2f18707d0fa7fa88e7d2ef69078902d4 100644 --- a/bt5/erp5_base/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml +++ b/bt5/erp5_base/PortalTypeAllowedContentTypeTemplateItem/allowed_content_types.xml @@ -21,6 +21,7 @@ <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> @@ -53,10 +54,15 @@ <item>Category Movement Group</item> <item>Causality Assignment Movement Group</item> <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> <item>Parent Explanation Movement Group</item> <item>Predicate</item> + <item>Property Assignment Movement Group</item> <item>Property Movement Group</item> <item>Quantity Sign Movement Group</item> <item>Requirement Movement Group</item> @@ -64,6 +70,7 @@ <item>Split Category Movement Group</item> <item>Split Movement Group</item> <item>Split Property Movement Group</item> + <item>Tax Line Delivery Movement Group</item> <item>Title Movement Group</item> <item>Variant Movement Group</item> <item>Variation Property Movement Group</item> diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision index 633a07769901eb809dc5c81a7130887878624251..8a2602231b523baf9bcc6d35eb763d81015c25f4 100644 --- a/bt5/erp5_base/bt/revision +++ b/bt5/erp5_base/bt/revision @@ -1 +1 @@ -685 \ No newline at end of file +686 \ No newline at end of file diff --git a/bt5/erp5_base/bt/template_action_path_list b/bt5/erp5_base/bt/template_action_path_list index 6bf32d043c482bf0f5f18474c7af4d14a7b10c83..5c28c0557c0aa6e388b4a8a29724109d0f82da31 100644 --- a/bt5/erp5_base/bt/template_action_path_list +++ b/bt5/erp5_base/bt/template_action_path_list @@ -36,6 +36,7 @@ Image | download Image | fullsize_view Image | view Link | view +Mirror Movement Group | view Monthly Range Movement Group | view Nested Line Movement Group | view Notification Message Module | view diff --git a/bt5/erp5_base/bt/template_portal_type_allowed_content_type_list b/bt5/erp5_base/bt/template_portal_type_allowed_content_type_list index 3efe3cf54e3ad62f78f7a743fbf268b1a5a5fed4..669e9541bc3928f7f6fef318009b9e459d65ef1a 100644 --- a/bt5/erp5_base/bt/template_portal_type_allowed_content_type_list +++ b/bt5/erp5_base/bt/template_portal_type_allowed_content_type_list @@ -9,6 +9,7 @@ Delivery Builder | Causality Assignment Movement Group Delivery Builder | Causality Movement Group Delivery Builder | Day Movement Group Delivery Builder | Delivery Causality Assignment Movement Group +Delivery Builder | Mirror Movement Group Delivery Builder | Monthly Range Movement Group Delivery Builder | Nested Line Movement Group Delivery Builder | Order Movement Group @@ -33,10 +34,15 @@ Order Builder | Base Variant Movement Group Order Builder | Category Movement Group 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 Order Builder | Parent Explanation Movement Group Order Builder | Predicate +Order Builder | Property Assignment Movement Group Order Builder | Property Movement Group Order Builder | Quantity Sign Movement Group Order Builder | Requirement Movement Group @@ -44,6 +50,7 @@ Order Builder | Root Applied Rule Causality Movement Group Order Builder | Split Category Movement Group Order Builder | Split Movement Group Order Builder | Split Property Movement Group +Order Builder | Tax Line Delivery Movement Group Order Builder | Title Movement Group Order Builder | Variant Movement Group Order Builder | Variation Property Movement Group diff --git a/bt5/erp5_base/bt/template_portal_type_id_list b/bt5/erp5_base/bt/template_portal_type_id_list index fea98886a5132aceed83be15b860c43827423f6c..83d951ebce7c7d1e4c560ddbb7a12e796827f4a5 100644 --- a/bt5/erp5_base/bt/template_portal_type_id_list +++ b/bt5/erp5_base/bt/template_portal_type_id_list @@ -24,6 +24,7 @@ Fax File Image Link +Mirror Movement Group Monthly Range Movement Group Nested Line Movement Group Notification Message diff --git a/product/ERP5/Document/MirrorMovementGroup.py b/product/ERP5/Document/MirrorMovementGroup.py new file mode 100644 index 0000000000000000000000000000000000000000..a496e796c574196b19c3443da606a43c8279b6b3 --- /dev/null +++ b/product/ERP5/Document/MirrorMovementGroup.py @@ -0,0 +1,72 @@ +############################################################################## +# +# 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 = {} + 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.setMappingValue(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()