From 6061603161bc49ba4a9f2e4a4ac366c88a95e586 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Wed, 3 Mar 2010 05:39:46 +0000 Subject: [PATCH] add Mirror Movement Group. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33302 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Mirror%20Movement%20Group/view.xml | 2 +- .../allowed_content_types.xml | 7 ++ bt5/erp5_base/bt/revision | 2 +- bt5/erp5_base/bt/template_action_path_list | 1 + ...late_portal_type_allowed_content_type_list | 7 ++ bt5/erp5_base/bt/template_portal_type_id_list | 1 + product/ERP5/Document/MirrorMovementGroup.py | 72 +++++++++++++++++++ 7 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 product/ERP5/Document/MirrorMovementGroup.py 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 197525691e..5bffd3566b 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 5127ff1f0c..d37974ec2f 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 633a077699..8a2602231b 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 6bf32d043c..5c28c0557c 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 3efe3cf54e..669e9541bc 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 fea98886a5..83d951ebce 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 0000000000..a496e796c5 --- /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() -- 2.30.9