From 5be88a84c38a7262ae2176a5e970fb9eb3f7d52e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 19 May 2008 15:43:08 +0000
Subject: [PATCH] check that we don't need write permission on the accounting
 transction to pass confirm or stop transition (they call an after script
 which sets the source/destination references)

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

diff --git a/product/ERP5/tests/testAccounting.py b/product/ERP5/tests/testAccounting.py
index de5999e349..8d729fcfb8 100644
--- a/product/ERP5/tests/testAccounting.py
+++ b/product/ERP5/tests/testAccounting.py
@@ -1733,6 +1733,30 @@ class TestTransactions(AccountingTestCase):
     self.assertEquals('code-2002-1', next_year_transaction.getSourceReference())
     self.assertEquals('2002-1', next_year_transaction.getDestinationReference())
 
+  def test_SourceDestinationReferenceSecurity(self):
+    # Check that we don't need specific roles to set source reference and
+    # destination reference, as long as we can pass the workflow transition
+
+    # clear all existing ids in portal ids
+    if hasattr(self.portal.portal_ids, 'dict_ids'):
+      self.portal.portal_ids.dict_ids.clear()
+
+    section_period_2001 = self.section.newContent(
+                        portal_type='Accounting Period',
+                        short_title='code-2001',
+                        start_date=DateTime(2001, 01, 01),
+                        stop_date=DateTime(2001, 12, 31))
+    section_period_2001.start()
+
+    accounting_transaction = self._makeOne(
+              destination_section_value=self.organisation_module.client_1,
+              start_date=DateTime(2001, 01, 01),
+              stop_date=DateTime(2001, 01, 01))
+    accounting_transaction.manage_permission('Modify portal content',
+                                             roles=['Manager'], acquire=0)
+    accounting_transaction.stop()
+    self.assertEquals('code-2001-1', accounting_transaction.getSourceReference())
+
   def test_SearchableText(self):
     transaction = self._makeOne(title='A new Transaction',
                                 description="A description",
-- 
2.30.9