Commit 0421df6f authored by Jérome Perrin's avatar Jérome Perrin

remove the implicit set of mirror section, because it makes it's to easy to add

transactions for another section in multi currency accounting.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16701 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 81b089c5
......@@ -62,74 +62,6 @@ class AccountingTransactionLine(DeliveryLine):
# Declarative interfaces
__implements__ = ( )
security.declarePrivate('_setSource')
def _setSource(self, value, portal_type=None):
"""
Set the source Account and implicitely the destination Account
using the source's mirror account.
"""
self._setCategoryMembership('source', value, base=0)
if self.getPortalType() not in \
self.getPortalBalanceTransactionLineTypeList() \
and value not in (None, ''):
source = self.getPortalObject().portal_categories.resolveCategory(value)
destination = self.getDestination()
if source is not None:
mirror_list = source.getDestinationList()
else:
mirror_list = []
if len(mirror_list) > 0 and destination not in mirror_list:
self._setCategoryMembership('destination', mirror_list[0], base=0)
security.declareProtected(Permissions.ModifyPortalContent, 'setSource')
def setSource(self, value):
"""
Set the source Account and implicitely the destination Account
using the source's mirror account, then reindex self.
"""
self._setSource(value)
self.reindexObject()
security.declarePrivate('_setDestination')
def _setDestination(self, value, portal_type=None):
"""
Set the destination Account and implicitely the source Account
using the source's mirror account.
"""
self._setCategoryMembership('destination', value, base=0)
if self.getPortalType() not in \
self.getPortalBalanceTransactionLineTypeList()\
and value not in (None, ''):
destination = self.getPortalObject().\
portal_categories.resolveCategory(value)
source = self.getSource()
if destination is not None:
mirror_list = destination.getDestinationList()
else:
mirror_list = []
if len(mirror_list) > 0 and source not in mirror_list:
self._setCategoryMembership('source', mirror_list[0], base=0)
security.declareProtected(Permissions.ModifyPortalContent, 'setDestination')
def setDestination(self, value):
"""
Set the destination Account and implicitely the source Account
using the source's mirror account, then reindex self.
"""
self._setDestination(value)
self.reindexObject()
security.declarePrivate('_edit')
def _edit(self, REQUEST = None, force_update = 0, **kw):
"""
Edit the object and set source/destination using magic methods.
"""
if kw.has_key('source'):
self._setSource(kw['source'])
elif kw.has_key('destination') :
self._setDestination(kw['destination'])
DeliveryLine._edit(self, REQUEST=REQUEST, force_update=force_update, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getInventoriatedQuantity')
def getInventoriatedQuantity(self):
......
......@@ -1445,63 +1445,6 @@ class TestAccounting(ERP5TypeTestCase):
bank_account=self.bank_account,
account_list=self.account_list )
def stepCreateAccountingTransactionAndCheckMirrorAccount(self,
sequence, **kw):
"""Check that mirror account are set automatically. """
account_list = sequence.get('account_list')
for account in account_list :
self.assertNotEquals(account.getDestinationValue(), None)
transaction = self.getAccountingModule().newContent(
portal_type = self.accounting_transaction_portal_type,
source_section_value = sequence.get('client'),
resource_value = sequence.get('EUR'),
created_by_builder = 1,
)
# setting both source and destination shouldn't use mirror accounts
destination = sequence.get('receivable_account')
for account in account_list :
transaction_line = transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type,
source = account.getRelativeUrl(),
destination = destination.getRelativeUrl(),
)
self.assertEquals( destination.getRelativeUrl(),
transaction_line.getDestination() )
# setting only a source must use mirror account as destination
for account in account_list :
transaction_line = transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type,
source = account.getRelativeUrl(),
)
self.assertEquals( account.getDestination(),
transaction_line.getDestination() )
# editing the destination later should not change the source once
# the mirror account has been set.
account = sequence.get('receivable_account')
destination = sequence.get('bank_account')
another_destination = sequence.get('expense_account')
account.setDestinationValueList(account_list)
transaction_line = transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type,
source = account.getRelativeUrl(), )
automatically_set_destination = transaction_line.getDestinationValue()
# get another account.
if automatically_set_destination == destination :
forced_destination = destination
else :
forced_destination = another_destination
# set all other accounts as mirror account to this one.
forced_destination.setDestinationValueList(account_list)
# change the destination and check the source didn't change.
transaction_line.edit(destination = forced_destination.getRelativeUrl())
self.assertEquals( transaction_line.getSourceValue(), account )
def getInvoicePropertyList(self):
"""Returns the list of properties for invoices, stored as
......@@ -2286,16 +2229,6 @@ class TestAccounting(ERP5TypeTestCase):
stepCheckInvoicesAreDraft
""", quiet=quiet)
def test_MirrorAccounts(self, quiet=QUIET, run=RUN_ALL_TESTS):
"""Tests using an account on one sides uses the mirror account
on the other size. """
if not run : return
self.playSequence("""
stepCreateEntities
stepCreateAccounts
stepCreateAccountingTransactionAndCheckMirrorAccount
""", quiet=quiet)
def test_Acquisition(self, quiet=QUIET, run=RUN_ALL_TESTS):
"""Tests acquisition, categories and portal types are well
configured. """
......
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