Commit e8e90c91 authored by Sebastien Robin's avatar Sebastien Robin

remove manage_beforeDelete into AccountingTransaction, we can now configure...

remove manage_beforeDelete into AccountingTransaction, we can now configure when we want to delete with the delete_action workflow transition

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13450 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21a035f4
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
############################################################################## ##############################################################################
from Globals import InitializeClass from Globals import InitializeClass
from Globals import DevelopmentMode
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
...@@ -66,18 +65,6 @@ class AccountingTransaction(Delivery): ...@@ -66,18 +65,6 @@ class AccountingTransaction(Delivery):
, PropertySheet.PaymentCondition , PropertySheet.PaymentCondition
) )
def manage_beforeDelete(self, item, container):
"""
Accounting transactions can only be deleted
in draft or cancelled state
"""
if not DevelopmentMode:
if self.getSimulationState() not in ("draft", "cancelled"):
from OFS.ObjectManager import BeforeDeleteException
raise BeforeDeleteException, \
"%s can only be deleted in draft or cancelled states." % self.getPortalType()
Delivery.manage_beforeDelete(self, item, container)
# Compatibility # Compatibility
# It may be necessary to create an alias after removing the Transaction class # It may be necessary to create an alias after removing the Transaction class
# Products.ERP5Type.Document.Transaction = AccountingTransaction # Products.ERP5Type.Document.Transaction = AccountingTransaction
...@@ -184,7 +184,6 @@ class AccountingTestCase(ERP5TypeTestCase): ...@@ -184,7 +184,6 @@ class AccountingTestCase(ERP5TypeTestCase):
"""Remove all documents, except the default ones. """Remove all documents, except the default ones.
""" """
get_transaction().abort() get_transaction().abort()
allowAccountingTransactionDeletion()
self.accounting_module.manage_delObjects( self.accounting_module.manage_delObjects(
list(self.accounting_module.objectIds())) list(self.accounting_module.objectIds()))
self.organisation_module.manage_delObjects([x for x in self.organisation_module.manage_delObjects([x for x in
...@@ -215,24 +214,6 @@ class AccountingTestCase(ERP5TypeTestCase): ...@@ -215,24 +214,6 @@ class AccountingTestCase(ERP5TypeTestCase):
'erp5_accounting_ui_test') 'erp5_accounting_ui_test')
def manage_beforeDelete(self, item, container):
Delivery.manage_beforeDelete(self, item, container)
def allowAccountingTransactionDeletion():
from Products.ERP5.Document.AccountingTransaction \
import AccountingTransaction
old_manage_beforeDelete = AccountingTransaction.manage_beforeDelete
AccountingTransaction.manage_beforeDelete = manage_beforeDelete
try:
from Products.ERP5Type.Document.AccountingTransaction \
import AccountingTransaction
AccountingTransaction.manage_beforeDelete = manage_beforeDelete
except ImportError:
# ERP5Type version of this class is only available when ERP5Type document
# registry has been initialized.
pass
class TestAccounting(ERP5TypeTestCase): class TestAccounting(ERP5TypeTestCase):
"""The first test for Accounting """The first test for Accounting
""" """
...@@ -300,7 +281,6 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -300,7 +281,6 @@ class TestAccounting(ERP5TypeTestCase):
All tests uses the same accounts and same entities, so we just cleanup All tests uses the same accounts and same entities, so we just cleanup
accounting module and simulation. """ accounting module and simulation. """
get_transaction().abort() get_transaction().abort()
allowAccountingTransactionDeletion()
for folder in (self.accounting_module, self.portal.portal_simulation): for folder in (self.accounting_module, self.portal.portal_simulation):
folder.manage_delObjects([i for i in folder.objectIds()]) folder.manage_delObjects([i for i in folder.objectIds()])
get_transaction().commit() get_transaction().commit()
......
...@@ -276,12 +276,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -276,12 +276,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
pl_id_list = [r for r in self.getPortal().purchase_packing_list_module.objectIds()] pl_id_list = [r for r in self.getPortal().purchase_packing_list_module.objectIds()]
self.getPortal().purchase_packing_list_module.manage_delObjects(pl_id_list) self.getPortal().purchase_packing_list_module.manage_delObjects(pl_id_list)
transaction_id_list = [] id_list = [r for r in self.getAccountingModule().objectIds()]
for transaction in self.getAccountingModule().objectValues(): self.getAccountingModule().manage_delObjects(id_list)
transaction_id_list.append(transaction.getId())
transaction.workflow_history = {}
self.getAccountingModule().manage_delObjects(item_id_list)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
......
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