Commit f051ee78 authored by Jérome Perrin's avatar Jérome Perrin

refactor SimulationMovement.isAccountable to call isAccountable on the rule



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7260 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 48930468
...@@ -100,6 +100,12 @@ class AppliedRule(XMLObject): ...@@ -100,6 +100,12 @@ class AppliedRule(XMLObject):
if rule is not None: if rule is not None:
rule.reset(self) rule.reset(self)
security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self, movement):
"""Tells wether generated movement needs to be accounted or not."""
return self.getSpecialiseValue().isAccountable(movement)
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, **kw): def expand(self, **kw):
""" """
......
...@@ -61,7 +61,16 @@ class InvoiceRule(DeliveryRule): ...@@ -61,7 +61,16 @@ class InvoiceRule(DeliveryRule):
, PropertySheet.DublinCore , PropertySheet.DublinCore
) )
# Simulation workflow security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self, movement):
"""Tells wether generated movement needs to be accounted or not.
Invoice movement are never accountable, so simulation movement for
invoice movements should not be accountable either.
"""
return 0
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, def expand(self, applied_rule,
movement_type_method='getPortalInvoiceMovementTypeList', **kw): movement_type_method='getPortalInvoiceMovementTypeList', **kw):
......
...@@ -62,6 +62,16 @@ class InvoicingRule(Rule): ...@@ -62,6 +62,16 @@ class InvoicingRule(Rule):
, PropertySheet.DublinCore , PropertySheet.DublinCore
) )
security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self, movement):
"""Tells wether generated movement needs to be accounted or not.
Invoice movement are never accountable, so simulation movement for
invoice movements should not be accountable either.
"""
return 0
security.declareProtected(Permissions.AccessContentsInformation, 'test') security.declareProtected(Permissions.AccessContentsInformation, 'test')
def test(self, movement): def test(self, movement):
""" """
...@@ -126,18 +136,16 @@ class InvoicingRule(Rule): ...@@ -126,18 +136,16 @@ class InvoicingRule(Rule):
start_date = my_context_movement.getStartDate(), start_date = my_context_movement.getStartDate(),
stop_date = my_context_movement.getStopDate(), stop_date = my_context_movement.getStopDate(),
source = my_context_movement.getSource(), source = my_context_movement.getSource(),
source_section = my_context_movement.getSourceSection(), source_section = source_section,
destination = my_context_movement.getDestination(), destination = my_context_movement.getDestination(),
destination_section = my_context_movement.getDestinationSection(), destination_section = destination_section,
# We do need to collect invoice lines to build invoices # We do need to collect invoice lines to build invoices
deliverable = 1 deliverable = 1,
) )
# Create one submovement which sources the transformation # Create one submovement which sources the transformation
Rule.expand(self, applied_rule, **kw) Rule.expand(self, applied_rule, **kw)
def isDeliverable(self, m): def isDeliverable(self, m):
resource = m.getResource() return m.getResource() is not None
if m.getResource() is None:
return 0
else:
return 1
...@@ -82,8 +82,18 @@ class Rule(XMLObject, Predicate): ...@@ -82,8 +82,18 @@ class Rule(XMLObject, Predicate):
, PropertySheet.DublinCore , PropertySheet.DublinCore
) )
# Instanciation as an appl security.declareProtected(Permissions.AccessContentsInformation,
security.declareProtected(Permissions.ModifyPortalContent, 'constructNewAppliedRule') 'isAccountable')
def isAccountable(self, movement):
"""Tells wether generated movement needs to be accounted or not.
Only account movements which are not associated to a delivery;
Whenever delivery is there, delivery has priority
"""
return movement.getDeliveryValue() is None
security.declareProtected(Permissions.ModifyPortalContent,
'constructNewAppliedRule')
def constructNewAppliedRule(self, context, id=None,**kw): def constructNewAppliedRule(self, context, id=None,**kw):
""" """
Creates a new applied rule which points to self Creates a new applied rule which points to self
...@@ -92,29 +102,18 @@ class Rule(XMLObject, Predicate): ...@@ -92,29 +102,18 @@ class Rule(XMLObject, Predicate):
if id is None: if id is None:
id = context.generateNewId() id = context.generateNewId()
if getattr(aq_base(context), id, None) is None: if getattr(aq_base(context), id, None) is None:
context.newContent(id=id, portal_type='Applied Rule', specialise_value=self,**kw) context.newContent(id=id,
portal_type='Applied Rule',
specialise_value=self,
**kw)
return context.get(id) return context.get(id)
# Simulation workflow # Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'reset')
def reset(self, applied_rule):
"""
DO WE NEED IT ?
-> this does either a diverge or a reset depending
on the position in the tree
if it is in root position, it is a solve
if it is in non root position, it is a diverse
"""
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, **kw): def expand(self, applied_rule, **kw):
""" """
Expands the current movement downward. Expands the current movement downward.
-> new status -> expanded
An applied rule can be expanded only if its parent movement An applied rule can be expanded only if its parent movement
is expanded. is expanded.
""" """
......
...@@ -173,10 +173,11 @@ class SimulationMovement(Movement): ...@@ -173,10 +173,11 @@ class SimulationMovement(Movement):
def isAccountable(self): def isAccountable(self):
""" """
Returns 1 if this needs to be accounted Returns 1 if this needs to be accounted
Only account movements which are not associated to a delivery Some Simulation movement corresponds to non accountable movements,
Whenever delivery is there, delivery has priority the parent applied rule decide wether this movement is accountable
or not.
""" """
return (self.getDeliveryValue() is None) return self.getParentValue().isAccountable(self)
# Ordering / Delivering # Ordering / Delivering
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
......
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