Commit 6b957b22 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_trade: add individual delivery rule

parent 796e7780
<?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}/Rule_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# 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.
#
##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.mixin.RuleMixin import RuleMixin
from erp5.component.mixin.MovementGeneratorMixin import MovementGeneratorMixin
from erp5.component.mixin.MovementCollectionUpdaterMixin import \
MovementCollectionUpdaterMixin
from erp5.component.interface.IRule import IRule
from erp5.component.interface.IDivergenceController import IDivergenceController
from erp5.component.interface.IMovementCollectionUpdater import IMovementCollectionUpdater
@zope.interface.implementer(IRule,
IDivergenceController,
IMovementCollectionUpdater,)
class IndividualDeliverySimulationRule(RuleMixin, MovementCollectionUpdaterMixin):
"""
Delivery Rule object make sure an Delivery in the simulation
is consistent with the real delivery
WARNING: what to do with movement split ?
"""
# CMF Type Definition
meta_type = 'ERP5 Individual Delivery Simulation Rule'
portal_type = 'Individual Delivery Simulation Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Default Properties
property_sheets = (
PropertySheet.Base,
PropertySheet.XMLObject,
PropertySheet.CategoryCore,
PropertySheet.DublinCore,
PropertySheet.Task,
PropertySheet.Predicate,
PropertySheet.Reference,
PropertySheet.Version,
PropertySheet.Rule
)
def _getMovementGenerator(self, context):
"""
Return the movement generator to use in the expand process
"""
return DeliveryRuleMovementGenerator(applied_rule=context, rule=self)
def _isProfitAndLossMovement(self, movement):
# For a kind of trade rule, a profit and loss movement lacks source
# or destination.
return (movement.getSource() is None or movement.getDestination() is None)
class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
def _getUpdatePropertyDict(self, input_movement):
# Override default mixin implementation
return {'order': None,
'delivery': None,}
def _getInputMovementList(self, movement_list=None, rounding=None):
movement_list = []
parent_value = self._applied_rule.getParentValue()
root_referene = parent_value.getExplanationReference()
delivery_id = parent_value.getDeliveryId()
resource_reference = parent_value.getResourceReference()
movement_reference = "%s-%s-%s" % (root_referene, delivery_id, resource_reference)
for index in range(int(parent_value.getQuantity())):
tmp = parent_value.asContext()
tmp.edit(
quantity=1,
reference='%s-%s' % (movement_reference, index)
)
movement_list.append(tmp)
return movement_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>IndividualDeliverySimulationRule</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.IndividualDeliverySimulationRule</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -45,6 +45,16 @@
<item>String Divergence Tester</item>
<item>Variation Divergence Tester</item>
</portal_type>
<portal_type id="Individual Delivery Simulation Rule">
<item>Category Membership Divergence Tester</item>
<item>DateTime Divergence Tester</item>
<item>Filtered Category Membership Equivalence Tester</item>
<item>Float Divergence Tester</item>
<item>Net Converted Quantity Divergence Tester</item>
<item>Specialise Divergence Tester</item>
<item>String Divergence Tester</item>
<item>Variation Divergence Tester</item>
</portal_type>
<portal_type id="Internal Order">
<item>Internal Order Line</item>
<item>Payment Condition</item>
......@@ -183,6 +193,7 @@
<portal_type id="Rule Tool">
<item>Delivery Root Simulation Rule</item>
<item>Delivery Simulation Rule</item>
<item>Individual Delivery Simulation Rule</item>
<item>Order Root Simulation Rule</item>
</portal_type>
<portal_type id="Sale Order">
......
<?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>rule_icon.gif</string> </value>
</item>
<item>
<key> <string>content_meta_type</string> </key>
<value> <string>ERP5 Delivery Simulation Rule</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>An ERP5 Rule...</string> </value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addDeliverySimulationRule</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>rule</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Individual Delivery Simulation Rule</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>IndividualDeliverySimulationRule</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -35,6 +35,10 @@
<type>Delivery Simulation Rule</type>
<workflow>edit_workflow, rule_validation_workflow</workflow>
</chain>
<chain>
<type>Individual Delivery Simulation Rule</type>
<workflow>edit_workflow, rule_validation_workflow</workflow>
</chain>
<chain>
<type>Internal Order</type>
<workflow>delivery_causality_interaction_workflow, delivery_causality_workflow, delivery_simulation_interaction_workflow, edit_workflow, order_workflow</workflow>
......
......@@ -14,6 +14,7 @@ Delivery Root Simulation Rule | view
Delivery Simulation Rule | view
Duplicate Inventory Constraint | view
First Causality Movement Group | view
Individual Delivery Simulation Rule | view
Internal Order Cell | view
Internal Order Line | price_view
Internal Order Line | profile_view
......
......@@ -5,6 +5,7 @@ document.erp5.ContainerLine
document.erp5.DeliveryRootSimulationRule
document.erp5.DeliverySimulationRule
document.erp5.DuplicateInventoryConstraint
document.erp5.IndividualDeliverySimulationRule
document.erp5.OrderCell
document.erp5.OrderLine
document.erp5.OrderRootSimulationRule
......
......@@ -26,6 +26,14 @@ Delivery Simulation Rule | Net Converted Quantity Divergence Tester
Delivery Simulation Rule | Specialise Divergence Tester
Delivery Simulation Rule | String Divergence Tester
Delivery Simulation Rule | Variation Divergence Tester
Individual Delivery Simulation Rule | Category Membership Divergence Tester
Individual Delivery Simulation Rule | DateTime Divergence Tester
Individual Delivery Simulation Rule | Filtered Category Membership Equivalence Tester
Individual Delivery Simulation Rule | Float Divergence Tester
Individual Delivery Simulation Rule | Net Converted Quantity Divergence Tester
Individual Delivery Simulation Rule | Specialise Divergence Tester
Individual Delivery Simulation Rule | String Divergence Tester
Individual Delivery Simulation Rule | Variation Divergence Tester
Internal Order Line | Internal Order Cell
Internal Order Line | Internal Order Line
Internal Order Module | Internal Order
......@@ -89,6 +97,7 @@ Returned Sale Packing List | Payment Condition
Returned Sale Packing List | Returned Sale Packing List Line
Rule Tool | Delivery Root Simulation Rule
Rule Tool | Delivery Simulation Rule
Rule Tool | Individual Delivery Simulation Rule
Rule Tool | Order Root Simulation Rule
Sale Order Line | Sale Order Cell
Sale Order Line | Sale Order Line
......
......@@ -11,6 +11,7 @@ Delivery Root Simulation Rule
Delivery Simulation Rule
Duplicate Inventory Constraint
First Causality Movement Group
Individual Delivery Simulation Rule
Internal Order
Internal Order Cell
Internal Order Line
......
......@@ -19,6 +19,8 @@ Delivery Root Simulation Rule | edit_workflow
Delivery Root Simulation Rule | rule_validation_workflow
Delivery Simulation Rule | edit_workflow
Delivery Simulation Rule | rule_validation_workflow
Individual Delivery Simulation Rule | edit_workflow
Individual Delivery Simulation Rule | rule_validation_workflow
Internal Order Cell | delivery_movement_causality_interaction_workflow
Internal Order Cell | delivery_movement_simulation_interaction_workflow
Internal Order Cell | edit_workflow
......
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