diff --git a/product/ERP5/Document/AppliedRule.py b/product/ERP5/Document/AppliedRule.py index 02bed149fba3c5f466321751100db5733d6d49bf..d444b2aea26cf615e57f91c03db8393994fa288b 100644 --- a/product/ERP5/Document/AppliedRule.py +++ b/product/ERP5/Document/AppliedRule.py @@ -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): """ diff --git a/product/ERP5/Document/InvoiceRule.py b/product/ERP5/Document/InvoiceRule.py index 8b7267c5e04b48e43dfebdf634861b3acee22e9e..7a56b30c554a56a1a9b3bf55376317700f1c5f4c 100644 --- a/product/ERP5/Document/InvoiceRule.py +++ b/product/ERP5/Document/InvoiceRule.py @@ -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): diff --git a/product/ERP5/Document/InvoicingRule.py b/product/ERP5/Document/InvoicingRule.py index 3bd26f7459def0f4fcb9985e997c9f398c1ec4ad..ea18411d0116750cc42ca6cc6cbfbaa06c835369 100644 --- a/product/ERP5/Document/InvoicingRule.py +++ b/product/ERP5/Document/InvoicingRule.py @@ -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 + diff --git a/product/ERP5/Document/Rule.py b/product/ERP5/Document/Rule.py index cdaf8a5b79a0f85f4e8d7198bac1e61352779db6..ddfa4ab329bf22ff0b55006a01ef379a6ef4bfcb 100644 --- a/product/ERP5/Document/Rule.py +++ b/product/ERP5/Document/Rule.py @@ -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. """ diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py index d436b129c9ec50a7b484602113fab5f146759e42..45f47a577945e95142aeb81fe75b72ff90bd9632 100644 --- a/product/ERP5/Document/SimulationMovement.py +++ b/product/ERP5/Document/SimulationMovement.py @@ -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,