From 4ab6a0bc1f567bbba190c06d0f0ec8eaf6969612 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Mon, 26 Apr 2004 14:26:53 +0000
Subject: [PATCH] New methods, validate, invalidate and getValidationState.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@738 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Entity.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/product/ERP5/Document/Entity.py b/product/ERP5/Document/Entity.py
index f8be5e59c9..f4e3afa011 100755
--- a/product/ERP5/Document/Entity.py
+++ b/product/ERP5/Document/Entity.py
@@ -29,6 +29,8 @@
 from Products.ERP5Type.Utils import assertAttributePortalType
 from AccessControl import ClassSecurityInfo
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
+from Products.CMFCore.WorkflowCore import WorkflowMethod
+from Products.CMFCore.utils import getToolByName
 
 class Entity:
     """
@@ -536,3 +538,29 @@ class Entity:
                             )
         self.default_email.fromText(coordinate)
 
+    security.declareProtected(Permissions.ModifyPortalContent, 'validate')
+    def validate(self):
+      """
+        Sets the entity to validated
+      """
+      pass
+
+    validate = WorkflowMethod(validate)
+
+    security.declareProtected(Permissions.ModifyPortalContent, 'invalidate')
+    def invalidate(self):
+      """
+        Sets the entity to invalidated
+      """
+      pass
+
+    invalidate = WorkflowMethod(invalidate)
+
+    security.declareProtected(Permissions.AccessContentsInformation, 'getValidationState')
+    def getValidationState(self, id_only=1):
+      """
+        Returns the current state in validation
+      """
+      portal_workflow = getToolByName(self, 'portal_workflow')
+      wf = portal_workflow.getWorkflowById('validation_workflow')
+      return wf._getWorkflowStateOf(self, id_only=id_only )
-- 
2.30.9