Commit 3fe08558 authored by Julien Muchembled's avatar Julien Muchembled

erp5_dummy_movement: cleanup

parent 487dc812
...@@ -27,11 +27,12 @@ ...@@ -27,11 +27,12 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5.Document.Movement import Movement 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 Dummy Movement' meta_type = 'ERP5 Dummy Movement'
...@@ -57,33 +58,15 @@ class DummyMovement(Movement): ...@@ -57,33 +58,15 @@ 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): # In order to make tests work with dummy movements that are not contained in
"""Returns property from delivery, in case if in Dummy Delivery, or movement""" # dummy deliveries, we must borrow a few methods from DummyDelivery.
if self.getParentValue().getPortalType() == 'Dummy Delivery':
return self.getParentValue().getSimulationState()
return getattr(self, property, default)
def getSimulationState(self): def getSimulationState(self):
return self._getPropertyDirectlyOrFromDummyDelivery( from erp5.document.DummyDelivery import DummyDelivery
'simulation_state', 'draft') parent = self.getParentValue()
if isinstance(parent, DummyDelivery):
def setSimulationState(self, state): self = parent
"""Directly sets a simulation state if not in Dummy Delivery.""" return DummyDelivery.getSimulationState.im_func(self)
if self.getParentValue().getPortalType() != 'Dummy Delivery':
self.simulation_state = state
else:
raise ValueError
def getCausalityState(self):
return self._getPropertyDirectlyOrFromDummyDelivery(
'causality_state', 'draft')
def setCausalityState(self, state):
"""Directly sets a causality state."""
if self.getParentValue().getPortalType() != 'Dummy Delivery':
self.simulation_state = state
else:
raise ValueError
def getDeliveryValue(self): def getDeliveryValue(self):
""" """
...@@ -103,6 +86,5 @@ class DummyMovement(Movement): ...@@ -103,6 +86,5 @@ class DummyMovement(Movement):
# return self, to have minimum support of getDeliveryValue # return self, to have minimum support of getDeliveryValue
return self return self
def hasCellContent(self): def hasCellContent(self):
return False return False
20 21
\ 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