From 97e7b755556eb1ae51339cf8f5cc6e03a979388d Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Tue, 2 Nov 2010 13:25:46 +0000
Subject: [PATCH] New testLegacySimulationAdvancedInvoicing and obvious fixes
 for testAdvancedInvoicing

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@39766 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../category_movement_group_on_delivery.xml   |  1 +
 .../category_movement_group_on_delivery.xml   |  1 +
 .../SaleInvoice_postGeneration.xml            |  2 +-
 product/ERP5/tests/testAdvancedInvoicing.py   |  3 +-
 product/ERP5/tests/testInvoice.py             |  3 ++
 product/ERP5Legacy/tests/__init__.py          |  4 +-
 .../testLegacySimulationAdvancedInvoicing.py  | 37 +++++++++++++++++++
 7 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 product/ERP5Legacy/tests/testLegacySimulationAdvancedInvoicing.py

diff --git a/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_purchase_invoice_builder/category_movement_group_on_delivery.xml b/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_purchase_invoice_builder/category_movement_group_on_delivery.xml
index 667e49edb0..729f642324 100644
--- a/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_purchase_invoice_builder/category_movement_group_on_delivery.xml
+++ b/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_purchase_invoice_builder/category_movement_group_on_delivery.xml
@@ -40,6 +40,7 @@
             <key> <string>tested_property</string> </key>
             <value>
               <tuple>
+                <string>specialise</string>
                 <string>delivery_mode</string>
                 <string>incoterm</string>
                 <string>source</string>
diff --git a/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_sale_invoice_builder/category_movement_group_on_delivery.xml b/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_sale_invoice_builder/category_movement_group_on_delivery.xml
index 667e49edb0..729f642324 100644
--- a/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_sale_invoice_builder/category_movement_group_on_delivery.xml
+++ b/bt5/erp5_advanced_invoicing/PathTemplateItem/portal_deliveries/advanced_sale_invoice_builder/category_movement_group_on_delivery.xml
@@ -40,6 +40,7 @@
             <key> <string>tested_property</string> </key>
             <value>
               <tuple>
+                <string>specialise</string>
                 <string>delivery_mode</string>
                 <string>incoterm</string>
                 <string>source</string>
diff --git a/bt5/erp5_advanced_invoicing/SkinTemplateItem/portal_skins/erp5_advanced_invoicing/SaleInvoice_postGeneration.xml b/bt5/erp5_advanced_invoicing/SkinTemplateItem/portal_skins/erp5_advanced_invoicing/SaleInvoice_postGeneration.xml
index 7b279b5a62..26c330c55f 100644
--- a/bt5/erp5_advanced_invoicing/SkinTemplateItem/portal_skins/erp5_advanced_invoicing/SaleInvoice_postGeneration.xml
+++ b/bt5/erp5_advanced_invoicing/SkinTemplateItem/portal_skins/erp5_advanced_invoicing/SaleInvoice_postGeneration.xml
@@ -78,7 +78,7 @@ invoice = context\n
 related_packing_list = invoice.getDefaultCausalityValue()\n
 \n
 # copy trade condition:\n
-if not context.getSpecialise():\n
+if not context.getSpecialise() and context.portal_skins.hasObject(\'erp5_simulation_legacy\'):\n
   related_order = related_packing_list.getDefaultCausalityValue()\n
   if related_order is not None:\n
     context.edit(specialise=related_order.getSpecialise())\n
diff --git a/product/ERP5/tests/testAdvancedInvoicing.py b/product/ERP5/tests/testAdvancedInvoicing.py
index a11b313add..8a65536292 100644
--- a/product/ERP5/tests/testAdvancedInvoicing.py
+++ b/product/ERP5/tests/testAdvancedInvoicing.py
@@ -37,7 +37,7 @@ from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
 from AccessControl.SecurityManagement import newSecurityManager
 from DateTime import DateTime
 from Products.ERP5Type.tests.Sequence import SequenceList
-from testInvoice import TestSaleInvoiceMixin
+from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin
 
 class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
   """Test methods for sale and purchase invoice.
@@ -364,6 +364,7 @@ class TestAdvancedInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
                               portal_type='Organisation', title='Vendor')
     invoice = self.portal.getDefaultModule(self.invoice_portal_type).newContent(
                               portal_type=self.invoice_portal_type,
+                              specialise=self.business_process,
                               start_date=DateTime(2008, 12, 31),
                               title='Invoice',
                               source_value=vendor,
diff --git a/product/ERP5/tests/testInvoice.py b/product/ERP5/tests/testInvoice.py
index 696ff8e965..9870bfecfa 100644
--- a/product/ERP5/tests/testInvoice.py
+++ b/product/ERP5/tests/testInvoice.py
@@ -143,6 +143,9 @@ class TestInvoiceMixin(TestPackingListMixin):
     user = uf.getUserById('test_invoice_user').__of__(uf)
     newSecurityManager(None, user)
 
+  def stepCreateSaleInvoiceTransactionRule(self, sequence, **kw) :
+    pass # see createBusinessProcess
+
   ## XXX move this to "Sequence class"
   def playSequence(self, sequence_string, quiet=0) :
     sequence_list = SequenceList()
diff --git a/product/ERP5Legacy/tests/__init__.py b/product/ERP5Legacy/tests/__init__.py
index 20b4a10a68..c19faccb1d 100644
--- a/product/ERP5Legacy/tests/__init__.py
+++ b/product/ERP5Legacy/tests/__init__.py
@@ -34,8 +34,8 @@ def Legacy_getBusinessTemplateList(cls):
         bt_list.append(bt)
         if bt == 'erp5_simulation':
           bt_list.append(bt +  '_legacy')
-        elif bt in ('erp5_accounting', 'erp5_mrp',
-                     'erp5_project', 'erp5_trade'):
+        elif bt in ('erp5_accounting', 'erp5_invoicing', 'erp5_mrp',
+                    'erp5_project', 'erp5_trade'):
           bt_list.append(bt +  '_simulation_legacy')
     return tuple(bt_list)
   cls.getBusinessTemplateList = Legacy_getBusinessTemplateList
diff --git a/product/ERP5Legacy/tests/testLegacySimulationAdvancedInvoicing.py b/product/ERP5Legacy/tests/testLegacySimulationAdvancedInvoicing.py
new file mode 100644
index 0000000000..05ba4bcf3c
--- /dev/null
+++ b/product/ERP5Legacy/tests/testLegacySimulationAdvancedInvoicing.py
@@ -0,0 +1,37 @@
+# -*- 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 testLegacySimulationInvoice
+sys.modules['Products.ERP5.tests.testInvoice'] = testLegacySimulationInvoice
+
+from Products.ERP5Legacy.tests import Legacy_getBusinessTemplateList
+from Products.ERP5.tests.testAdvancedInvoicing import *
+
+Legacy_getBusinessTemplateList(TestAdvancedInvoice)
+TestAdvancedInvoice.business_process = None
-- 
2.30.9