Commit 80023d59 authored by Jérome Perrin's avatar Jérome Perrin

Add interface for Rules



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7104 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 31dc6d03
...@@ -56,6 +56,9 @@ class AmortisationRule(Rule): ...@@ -56,6 +56,9 @@ class AmortisationRule(Rule):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
......
...@@ -48,6 +48,9 @@ class DeliveryRule(Rule): ...@@ -48,6 +48,9 @@ class DeliveryRule(Rule):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
...@@ -46,6 +46,9 @@ class InvoiceRule(DeliveryRule): ...@@ -46,6 +46,9 @@ class InvoiceRule(DeliveryRule):
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
......
...@@ -49,11 +49,14 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -49,11 +49,14 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
...@@ -52,6 +52,9 @@ class InvoicingRule(Rule): ...@@ -52,6 +52,9 @@ class InvoicingRule(Rule):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
...@@ -48,6 +48,9 @@ class OrderRule(DeliveryRule): ...@@ -48,6 +48,9 @@ class OrderRule(DeliveryRule):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
......
...@@ -54,6 +54,9 @@ class PaymentRule(Rule): ...@@ -54,6 +54,9 @@ class PaymentRule(Rule):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
...@@ -69,7 +72,7 @@ class PaymentRule(Rule): ...@@ -69,7 +72,7 @@ class PaymentRule(Rule):
if 'receivable' in movement.getId() : ### TODO: expand 'payable' too if 'receivable' in movement.getId() : ### TODO: expand 'payable' too
parent = movement.getParentValue() parent = movement.getParentValue()
if parent.getPortalType()=='Applied Rule' \ if parent.getPortalType()=='Applied Rule' \
and parent.getSpecialiseId()=='default_invoice_transaction_rule': and parent.getSpecialiseId()=='default_invoice_transaction_rule':
#LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent ))) #LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent )))
return 1 return 1
return 0 return 0
...@@ -103,11 +106,11 @@ class PaymentRule(Rule): ...@@ -103,11 +106,11 @@ class PaymentRule(Rule):
receivable_movement = applied_rule.newContent( receivable_movement = applied_rule.newContent(
type_name = payment_line_type, type_name = payment_line_type,
id = receivable_id) id = receivable_id)
# TODO: specify this using a rule in portal_rules # TODO: specify this using a rule in portal_rules
# TODO: generate many movement according to different trade conditions # TODO: generate many movement according to different trade conditions
bank_movement.edit( bank_movement.edit(
resource = my_parent_movement.getResource(), resource = my_parent_movement.getResource(),
quantity = my_parent_movement.getQuantity(), quantity = my_parent_movement.getQuantity(),
source = 'account/banques_etablissements_financiers', # XXX Not Generic source = 'account/banques_etablissements_financiers', # XXX Not Generic
destination = 'account/banques_etablissements_financiers', # XXX Not Generic destination = 'account/banques_etablissements_financiers', # XXX Not Generic
...@@ -115,7 +118,7 @@ class PaymentRule(Rule): ...@@ -115,7 +118,7 @@ class PaymentRule(Rule):
destination_section = my_parent_movement.getDestinationSection(), destination_section = my_parent_movement.getDestinationSection(),
) )
receivable_movement.edit( receivable_movement.edit(
resource = my_parent_movement.getResource(), resource = my_parent_movement.getResource(),
quantity = - my_parent_movement.getQuantity(), quantity = - my_parent_movement.getQuantity(),
source = 'account/creance_client', # XXX Not Generic source = 'account/creance_client', # XXX Not Generic
destination = 'account/dette_fournisseur', # XXX Not Generic destination = 'account/dette_fournisseur', # XXX Not Generic
......
...@@ -49,6 +49,9 @@ class ProductionOrderRule(OrderRule): ...@@ -49,6 +49,9 @@ class ProductionOrderRule(OrderRule):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
...@@ -71,6 +71,9 @@ class Rule(XMLObject, Predicate): ...@@ -71,6 +71,9 @@ class Rule(XMLObject, Predicate):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
......
...@@ -51,6 +51,8 @@ class TransformationRule(Rule): ...@@ -51,6 +51,8 @@ class TransformationRule(Rule):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
...@@ -134,6 +134,8 @@ class TransformationSourcingRule(Rule): ...@@ -134,6 +134,8 @@ class TransformationSourcingRule(Rule):
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
__implements__ = ( Interface.Predicate,
Interface.Rule )
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
......
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
try:
from Interface import Interface
except ImportError:
# for Zope versions before 2.6.0
from Interface import Base as Interface
class Rule(Interface):
"""A Rule describes transformations of documents.
"""
def constructNewAppliedRule(context):
"""Create a new applied rule in the context.
An applied rule is an instanciation of a Rule. The applied rule is
linked to the Rule through the `specialise` relation.
"""
def expand(applied_rule):
"""Expand this applied rule to create new documents inside the
applied rule.
"""
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