Commit 38a61741 authored by Julien Muchembled's avatar Julien Muchembled

New testLegacyAccountingReports

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38427 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e618dc84
......@@ -27,10 +27,9 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.Document.DeliveryRootSimulationRule \
import DeliveryRootSimulationRule
from Products.ERP5Legacy.Document.DeliveryRule import DeliveryRule
class AccountingTransactionRootSimulationRule(DeliveryRootSimulationRule):
class AccountingTransactionRootSimulationRule(DeliveryRule):
"""
Accounting Transaction Root Simulation Rule is a root level rule for
Accounting Transaction.
......@@ -43,6 +42,13 @@ class AccountingTransactionRootSimulationRule(DeliveryRootSimulationRule):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
}
def _getInputMovementList(self, applied_rule):
"""Return list of movements from delivery"""
delivery = applied_rule.getDefaultCausalityValue()
......
......@@ -50,19 +50,3 @@ class DeliveryRootSimulationRule(DeliveryRule):
return {
'delivery': movement.getRelativeUrl(),
}
# Fix subclasses (ex: AccountingTransactionRootSimulationRule)
from Products.ERP5.Document import DeliveryRootSimulationRule as original_module
original_class = original_module.DeliveryRootSimulationRule
try:
original_module.DeliveryRootSimulationRule = DeliveryRootSimulationRule
import gc, os, sys
from Products.ERP5Type.Utils import importLocalDocument
for bases in gc.get_referrers(original_class):
if type(bases) is tuple:
for subclass in gc.get_referrers(bases):
if getattr(subclass, '__bases__', None) is bases:
importLocalDocument(subclass.__name__,
os.path.dirname(sys.modules[subclass.__module__].__file__))
finally:
original_module.DeliveryRootSimulationRule = original_class
AccountingTransactionRootSimulationRule
BusinessProcess
DeliveryRootSimulationRule
DeliverySimulationRule
......
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.Document.DeliveryRootSimulationRule \
import DeliveryRootSimulationRule, DeliveryRuleMovementGenerator
class AccountingTransactionRootSimulationRule(DeliveryRootSimulationRule):
"""
Accounting Transaction Root Simulation Rule is a root level rule for
Accounting Transaction.
"""
# CMF Type Definition
meta_type = 'ERP5 Accounting Transaction Root Simulation Rule'
portal_type = 'Accounting Transaction Root Simulation Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getMovementGenerator(self, context):
"""
Return the movement generator to use in the expand process
"""
return AccountingTransactionRuleMovementGenerator(applied_rule=context,
rule=self)
class AccountingTransactionRuleMovementGenerator(DeliveryRuleMovementGenerator):
def _getPortalDeliveryMovementTypeList(self):
return self._rule.getPortalObject().getPortalAccountingMovementTypeList()
......@@ -92,6 +92,9 @@ class DeliveryRootSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Pred
class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
def _getPortalDeliveryMovementTypeList(self):
return self._rule.getPortalObject().getPortalDeliveryMovementTypeList()
def _getInputMovementList(self, movement_list=None, rounding=None):
"""Input movement list comes from delivery"""
delivery = self._applied_rule.getDefaultCausalityValue()
......@@ -101,7 +104,7 @@ class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
result = []
existing_movement_list = self._applied_rule.objectValues()
for movement in delivery.getMovementList(
portal_type=delivery.getPortalDeliveryMovementTypeList()):
portal_type=self._getPortalDeliveryMovementTypeList()):
simulation_movement = self._getDeliveryRelatedSimulationMovement(movement)
if simulation_movement is None or \
simulation_movement in existing_movement_list:
......
......@@ -232,7 +232,7 @@ class AccountingTestCase(ERP5TypeTestCase):
# some default content created.
return ('erp5_base', 'erp5_pdm', 'erp5_simulation', 'erp5_trade',
'erp5_accounting', 'erp5_project', 'erp5_accounting_ui_test',
'erp5_ods_style')
'erp5_ods_style', 'erp5_simulation_test')
class TestAccounts(AccountingTestCase):
......
......@@ -3709,12 +3709,9 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
def setUp(self):
# FIXME: use afterSetUp, and fix AccountingTestCase to use afterSetUp
AccountingTestCase.setUp(self)
if os.environ.get('erp5_save_data_fs'):
return
self.login('ERP5TypeTestCase')
def afterSetUp(self):
AccountingTestCase.afterSetUp(self)
self.login()
# create some functions
function = self.portal.portal_categories.function
if function._getOb('a', None) is None:
......@@ -3739,7 +3736,7 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
title='Project 2')
preference = self.portal.portal_preferences.getActivePreference()
preference.edit(
preference._edit(
preferred_accounting_transaction_line_function_base_category='function',
preferred_accounting_transaction_line_analytic_base_category_list=(
'product_line', ),)
......@@ -3777,13 +3774,14 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
product_line_value=None,
source_credit=700.0),
))
transaction.commit()
self.tic()
self.login(self.username)
def beforeTearDown(self):
self.login('ERP5TypeTestCase')
transaction.abort()
AccountingTestCase.beforeTearDown(self)
preference = self.portal.portal_preferences.getActivePreference()
preference.edit(
preference._edit(
preferred_accounting_transaction_line_function_base_category=None,
preferred_accounting_transaction_line_analytic_base_category_list=())
transaction.commit()
......
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Julien Muchembled <jm@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import sys
from Products.ERP5Legacy.tests import testLegacyAccounting
sys.modules['Products.ERP5.tests.testAccounting'] = testLegacyAccounting
from Products.ERP5.tests.testAccountingReports import *
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