Commit 007f2e0f authored by Jérome Perrin's avatar Jérome Perrin

Fix unindexing of balance transaction:

- make balance transaction line indexable
- pass all archive related parameters during delta indexation
- stop cleaning up manually in tear down


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36498 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 456c0f5d
......@@ -404,11 +404,11 @@ class BalanceTransaction(AccountingTransaction, Inventory):
This method must return a function that accepts properties keywords
arguments and returns a temp object edited with those properties.
"""
from Products.ERP5Type.Document import newTempBalanceTransactionLine
from Products.ERP5Type.Document import newTempAccountingTransactionLine
def factory(*args, **kw):
doc = newTempBalanceTransactionLine(self, kw.pop('id', self.getId()),
uid=self.getUid())
doc = newTempAccountingTransactionLine(self, kw.pop('id', self.getId()),
uid=self.getUid())
doc.portal_type = 'Balance Transaction Line'
relative_url = kw.pop('relative_url', None)
destination_total_asset_price = kw.pop('total_price', None)
if destination_total_asset_price is not None:
......@@ -459,16 +459,15 @@ class BalanceTransaction(AccountingTransaction, Inventory):
"""
sql_catalog_id = kw.pop("sql_catalog_id", None)
disable_archive = kw.pop("disable_archive", 0)
immediate_reindex_archive = sql_catalog_id is not None
if self.getSimulationState() in self.getPortalDraftOrderStateList() + (
'deleted',):
# this prevent from trying to calculate stock
# with not all properties defined and thus making
# request with no condition in mysql
object_list = [self]
immediate_reindex_archive = sql_catalog_id is not None
self.portal_catalog.catalogObjectList(
object_list,
[self],
sql_catalog_id = sql_catalog_id,
disable_archive=disable_archive,
immediate_reindex_archive=immediate_reindex_archive)
......@@ -489,9 +488,9 @@ class BalanceTransaction(AccountingTransaction, Inventory):
self.portal_catalog.catalogObjectList([self])
# Catalog differences calculated from lines
self.portal_catalog.catalogObjectList(stock_object_list,
method_id_list=('z_catalog_stock_list',
'z_catalog_object_list',
'z_catalog_movement_category_list'),
disable_cache=1, check_uid=0)
self.portal_catalog.catalogObjectList(stock_object_list[::],
method_id_list=('z_catalog_stock_list',),
disable_cache=1, check_uid=0,
sql_catalog_id=sql_catalog_id,
disable_archive=disable_archive,
immediate_reindex_archive=immediate_reindex_archive)
......@@ -43,7 +43,7 @@ class BalanceTransactionLine(AccountingTransactionLine, InventoryLine):
meta_type = 'ERP5 Balance Transaction Line'
portal_type = 'Balance Transaction Line'
add_permission = Permissions.AddPortalContent
isIndexable = ConstantGetter('isIndexable', value=False)
isInventoryMovement = ConstantGetter('isInventoryMovement', value=True)
# Declarative security
security = ClassSecurityInfo()
......
......@@ -863,14 +863,6 @@ class TestTransactionValidation(AccountingTestCase):
class TestClosingPeriod(AccountingTestCase):
"""Various tests for closing the period.
"""
def beforeTearDown(self):
transaction.abort()
# we manually remove the content of stock table, because unindexObject
# might not work correctly on Balance Transaction, and we don't want
# leave something in stock table that will change the next test.
self.portal.erp5_sql_connection.manage_test('truncate stock')
transaction.commit()
def test_createBalanceOnNode(self):
period = self.section.newContent(portal_type='Accounting Period')
period.setStartDate(DateTime(2006, 1, 1))
......@@ -1781,7 +1773,8 @@ class TestClosingPeriod(AccountingTestCase):
destination_credit=100,)
balance.stop()
balance.deliver()
balance.immediateReindexObject()
transaction.commit()
self.tic()
# now check inventory
stool = self.getSimulationTool()
......@@ -1818,6 +1811,11 @@ class TestClosingPeriod(AccountingTestCase):
balance.reindexObject()
transaction.commit()
self.tic()
# the account 'receivable' still has a balance of 100
node_uid = self.account_module.receivable.getUid()
self.assertEquals(100, stool.getInventory(
section_uid=self.section.getUid(),
node_uid=node_uid))
def test_InventoryIndexingNodeDiffOnNode(self):
# Balance Transactions are indexed as Inventories.
......
......@@ -52,12 +52,6 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
...
"""
def beforeTearDown(self):
# workaround the fact that Balance Transaction Line are not unindexed
# correctly when removed
self.portal.erp5_sql_connection.manage_test('TRUNCATE TABLE stock')
transaction.commit()
def testJournal(self):
# Journal report.
# this will be a journal for 2006/02/02, for Sale Invoice Transaction
......
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