Commit cd375713 authored by Łukasz Nowak's avatar Łukasz Nowak

- support DummyMovement to be in DummyDelivery

 - set up is as movement in orders and deliveries


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28117 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b046fbf2
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com> # Jerome Perrin <jerome@nexedi.com>
# Łukasz Nowak <luke@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -32,8 +34,8 @@ from Products.ERP5.Document.Movement import Movement ...@@ -32,8 +34,8 @@ from Products.ERP5.Document.Movement import Movement
class DummyMovement(Movement): class DummyMovement(Movement):
"""Dummy Movement for testing purposes.""" """Dummy Movement for testing purposes."""
meta_type = 'ERP5 Movement' meta_type = 'ERP5 Dummy Movement'
portal_type = 'Movement' portal_type = 'Dummy Movement'
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
...@@ -61,25 +63,38 @@ class DummyMovement(Movement): ...@@ -61,25 +63,38 @@ class DummyMovement(Movement):
"""Our dummy movement are always accountable.""" """Our dummy movement are always accountable."""
return getattr(self, 'is_accountable', 1) return getattr(self, 'is_accountable', 1)
def _getPropertyDirectlyOrFromDummyDelivery(self, property, default=None):
"""Returns property from delivery, in case if in Dummy Delivery, or movement"""
if self.getParentValue().getPortalType() == 'Dummy Delivery':
return self.getParentValue().getSimulationState()
return getattr(self, property, default)
def getSimulationState(self): def getSimulationState(self):
"""Directly returns a simulation state.""" return self._getPropertyDirectlyOrFromDummyDelivery(
return getattr(self, 'simulation_state', 'draft') 'simulation_state', 'draft')
def setSimulationState(self, state): def setSimulationState(self, state):
"""Directly sets a simulation state.""" """Directly sets a simulation state if not in Dummy Delivery."""
self.simulation_state = state if self.getParentValue().getPortalType() != 'Dummy Delivery':
self.simulation_state = state
else:
raise ValueError
def getCausalityState(self): def getCausalityState(self):
"""Directly returns a causality state.""" return self._getPropertyDirectlyOrFromDummyDelivery(
return getattr(self, 'simulation_state', 'draft') 'causality_state', 'draft')
def setCausalityState(self, state): def setCausalityState(self, state):
"""Directly sets a causality state.""" """Directly sets a causality state."""
self.causality_state = state if self.getParentValue().getPortalType() != 'Dummy Delivery':
self.simulation_state = state
else:
raise ValueError
def getDeliveryValue(self): def getDeliveryValue(self):
"""A dummy movement doesn't have a delivery relation, so return self as delivery. """A dummy movement doesn't have a delivery relation, so return self as delivery.
""" """
return self return self
def hasCellContent(self):
return False
...@@ -3,21 +3,12 @@ ...@@ -3,21 +3,12 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="ERP5TypeInformation" module="Products.ERP5Type.ERP5Type"/>
<string>Products.ERP5Type.ERP5Type</string> <tuple/>
<string>ERP5TypeInformation</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_actions</string> </key> <key> <string>_actions</string> </key>
<value> <value>
...@@ -30,12 +21,6 @@ ...@@ -30,12 +21,6 @@
<dictionary/> <dictionary/>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_roles</string> </key> <key> <string>_roles</string> </key>
<value> <value>
...@@ -81,7 +66,10 @@ ...@@ -81,7 +66,10 @@
<item> <item>
<key> <string>group_list</string> </key> <key> <string>group_list</string> </key>
<value> <value>
<tuple/> <tuple>
<string>delivery_movement</string>
<string>order_movement</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -98,6 +86,10 @@ ...@@ -98,6 +86,10 @@
<key> <string>init_script</string> </key> <key> <string>init_script</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>permission</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>property_sheet_list</string> </key> <key> <string>property_sheet_list</string> </key>
<value> <value>
......
0.1 0.2
\ No newline at end of file \ 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