From 3b0cd2e41921b54e0a7fb2d348c203e81c7810dc Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Thu, 22 Apr 2010 11:55:27 +0000
Subject: [PATCH] same as r34722 (in Invoice Simulation Rule, source should be
 source_administration of the input movement or its order's source. Same for
 destination).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34724 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../DocumentTemplateItem/InvoiceSimulationRule.py  | 14 +++++++++-----
 bt5/erp5_simulation/bt/revision                    |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
index 39d1af42b0..9e122d722d 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
@@ -95,10 +95,8 @@ class InvoicingRuleMovementGenerator(MovementGeneratorMixin):
   def getGeneratedMovementList(self, context, movement_list=None,
                                 rounding=False):
     """
-    Input movement list comes from order
-
-    XXX This implementation is very primitive, and does not support BPM,
-    i.e. business paths are not taken into account.
+    In Invoice Simulation Rule, source should be source_administration
+    of the input movement or its order's source. Same for destination.
     """
     ret = []
     rule = context.getSpecialiseValue()
@@ -106,7 +104,13 @@ class InvoicingRuleMovementGenerator(MovementGeneratorMixin):
             ._getInputMovementAndPathTupleList(context):
       kw = self._getPropertyAndCategoryList(input_movement, business_path,
                                             rule)
-      kw.update({'order':None,'delivery':None})
+      root_simulation_movement = input_movement.getRootSimulationMovement()
+      source = input_movement.getSourceAdministration() or \
+               root_simulation_movement.getSource()
+      destination = input_movement.getDestinationAdministration() or \
+                    root_simulation_movement.getDestination()
+      kw.update({'order':None, 'delivery':None,
+                 'source':source, 'destination':destination})
       simulation_movement = context.newContent(
         portal_type=RuleMixin.movement_type,
         temp_object=True,
diff --git a/bt5/erp5_simulation/bt/revision b/bt5/erp5_simulation/bt/revision
index c147342cbe..9d1ce53f8c 100644
--- a/bt5/erp5_simulation/bt/revision
+++ b/bt5/erp5_simulation/bt/revision
@@ -1 +1 @@
-81
\ No newline at end of file
+82
\ No newline at end of file
-- 
2.30.9