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):
if rule is not None:
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')
def expand(self, **kw):
"""
......
......@@ -60,8 +60,17 @@ class InvoiceRule(DeliveryRule):
, PropertySheet.CategoryCore
, 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
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule,
movement_type_method='getPortalInvoiceMovementTypeList', **kw):
......
......@@ -62,6 +62,16 @@ class InvoicingRule(Rule):
, 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')
def test(self, movement):
"""
......@@ -126,18 +136,16 @@ class InvoicingRule(Rule):
start_date = my_context_movement.getStartDate(),
stop_date = my_context_movement.getStopDate(),
source = my_context_movement.getSource(),
source_section = my_context_movement.getSourceSection(),
source_section = source_section,
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
deliverable = 1
deliverable = 1,
)
# Create one submovement which sources the transformation
Rule.expand(self, applied_rule, **kw)
def isDeliverable(self, m):
resource = m.getResource()
if m.getResource() is None:
return 0
else:
return 1
return m.getResource() is not None
......@@ -81,9 +81,19 @@ class Rule(XMLObject, Predicate):
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
)
# Instanciation as an appl
security.declareProtected(Permissions.ModifyPortalContent, 'constructNewAppliedRule')
security.declareProtected(Permissions.AccessContentsInformation,
'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):
"""
Creates a new applied rule which points to self
......@@ -92,29 +102,18 @@ class Rule(XMLObject, Predicate):
if id is None:
id = context.generateNewId()
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)
# 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')
def expand(self, applied_rule, **kw):
"""
Expands the current movement downward.
-> new status -> expanded
An applied rule can be expanded only if its parent movement
is expanded.
"""
......
......@@ -173,10 +173,11 @@ class SimulationMovement(Movement):
def isAccountable(self):
"""
Returns 1 if this needs to be accounted
Only account movements which are not associated to a delivery
Whenever delivery is there, delivery has priority
Some Simulation movement corresponds to non accountable movements,
the parent applied rule decide wether this movement is accountable
or not.
"""
return (self.getDeliveryValue() is None)
return self.getParentValue().isAccountable(self)
# Ordering / Delivering
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