Commit bbf94fa7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Update Movement Group to not merge based on SPL causality

    extend test to diff movement
parent 7a04d633
......@@ -45,9 +45,19 @@ class RootAppliedRuleCausalityCausalityMovementGroup(MovementGroup):
return property_dict
def test(self, movement, property_dict, **kw):
# We can always update
if 'root_causality_causality_value_list' in property_dict:
root_causality_causality_value_list = property_dict['root_causality_causality_value_list']
if root_causality_causality_value_list[0] is None and not movement.getCausalityValueList():
return True, property_dict
for causality in movement.getCausalityValueList():
test_root_causality_causality_value = causality.getCausalityValue()
if test_root_causality_causality_value == root_causality_causality_value_list[0]:
return True, property_dict
# We can always update
return False, property_dict
def _getRootCausalityCausalityValue(self, movement):
""" Get the causality value of the causality of the root applied rule for a movement """
root_causality = movement.getRootAppliedRule().getCausalityValue()
......
##############################################################################
#
# Copyright (c) 2008 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 erp5.component.document.erp5_version.RootAppliedRuleCausalityMovementGroup\
import RootAppliedRuleCausalityMovementGroup as ERP5RootAppliedRuleCausalityMovementGroup
class RootAppliedRuleCausalityMovementGroup(ERP5RootAppliedRuleCausalityMovementGroup):
"""
The purpose of MovementGroup is to define how movements are grouped,
and how values are updated from simulation movements.
This movement group is used to group movements whose root apply rule
has the same causality.
This overwrites the default for not always update, but check the information.
"""
def test(self, movement, property_dict, **kw):
if 'root_causality_value_list' in property_dict:
root_causality_value_list = property_dict['root_causality_value_list']
for simulation_movement in movement.getDeliveryRelatedValueList():
if self._getRootCausalityValue(simulation_movement) == root_causality_value_list[0]:
return True, property_dict
# No don't update
return False, property_dict
\ No newline at end of file
<?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>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>RootAppliedRuleCausalityMovementGroup</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_slapos.RootAppliedRuleCausalityMovementGroup</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_slapos</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</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/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<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">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<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>
......@@ -27,7 +27,7 @@
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -11,6 +11,7 @@
<value>
<tuple>
<string>collect_order_group/delivery</string>
<string>divergence_scope/category</string>
</tuple>
</value>
</item>
......@@ -26,7 +27,7 @@
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>3</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Root Applied Rule Causality Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>collect_order_group/line</string>
<string>divergence_scope/category</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>root_applied_rule_causality_movement_group_on_line</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>Root Applied Rule Causality Movement Group</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>root_applied_rule_causality_movement_group_on_line</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -48,10 +48,12 @@ if context.getStartDate() is None:
max_stop_date = DateTime().earliestTime()
context.setStopDate(max_stop_date)
if context.getCausalityState() == 'draft':
context.startBuilding()
comment = translateString('Initialised by Delivery Builder.')
if invoice.getCausalityState() == 'draft':
invoice.startBuilding(comment=comment)
if invoice.portal_workflow.isTransitionPossible(invoice, 'plan'):
invoice.plan(comment=comment)
if invoice.portal_workflow.isTransitionPossible(invoice, 'confirm'):
......
document.erp5.SlapOSAccountingQuantityUpdatingOrderBuilder
document.erp5.SubscriptionItemRootSimulationRule
document.erp5.RootAppliedRuleCausalityCausalityMovementGroup
document.erp5_slapos.RootAppliedRuleCausalityMovementGroup
\ No newline at end of file
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