diff --git a/product/ERP5/Document/PaymentCondition.py b/product/ERP5/Document/PaymentCondition.py index 14d6e178255e93308c180d0b7444df970db185f8..d62ed2790c492dda5c5cca2ab236d76761f1dd13 100644 --- a/product/ERP5/Document/PaymentCondition.py +++ b/product/ERP5/Document/PaymentCondition.py @@ -32,26 +32,45 @@ from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5.Document.TradeModelLine import TradeModelLine class PaymentCondition(TradeModelLine): - """ - Payment Conditions are used to define all the parameters of a payment - """ - - meta_type = 'ERP5 Payment Condition' - portal_type = 'Payment Condition' - add_permission = Permissions.AddPortalContent - - # Declarative security - security = ClassSecurityInfo() - security.declareObjectProtected(Permissions.AccessContentsInformation) - - # Declarative properties - property_sheets = ( PropertySheet.Base - , PropertySheet.XMLObject - , PropertySheet.CategoryCore - , PropertySheet.DublinCore - , PropertySheet.Amount - , PropertySheet.PaymentCondition - , PropertySheet.Chain - , PropertySheet.SortIndex - , PropertySheet.TradeModelLine - ) + """ + Payment Conditions are used to define all the parameters of a payment + """ + + meta_type = 'ERP5 Payment Condition' + portal_type = 'Payment Condition' + add_permission = Permissions.AddPortalContent + + # Declarative security + security = ClassSecurityInfo() + security.declareObjectProtected(Permissions.AccessContentsInformation) + + # Declarative properties + property_sheets = ( PropertySheet.Base + , PropertySheet.XMLObject + , PropertySheet.CategoryCore + , PropertySheet.DublinCore + , PropertySheet.Amount + , PropertySheet.PaymentCondition + , PropertySheet.Chain + , PropertySheet.SortIndex + , PropertySheet.TradeModelLine + ) + + security.declareProtected(Permissions.AccessContentsInformation, + 'getCalculationScript') + def getCalculationScript(self, context): + # In the case of Payment Condition, unlike Trade Model Line, + # it is not realistic to share the same method, so do not acquire + # a script from its parent. + # + # It is always complicated and different how to adopt the calculation of + # payment dates for each user, and it is not practical to force the + # user to set a script id in every Payment Condition, so it is better + # to use a type-based method here, unless a script is explicitly set. + script_id = self.getCalculationScriptId() + if script_id is not None: + method = getattr(context, script_id) + return method + method = self._getTypeBasedMethod('calculateMovement') + return method +