From 9d44c79bd1a296082cfe6dff7d14ba6a4e6a1955 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 23 Jul 2007 09:01:52 +0000
Subject: [PATCH] When setting source|destination reference, assign 1 for the
 first reference, not 0.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15273 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/setReferences.xml                 | 19 ++++++++++---------
 bt5/erp5_accounting/bt/revision               |  2 +-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/setReferences.xml b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/setReferences.xml
index da5221b7a8..b63127e588 100644
--- a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/setReferences.xml
+++ b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/setReferences.xml
@@ -68,8 +68,7 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string># Purchase Invoice Transaction or Sale Invoice Transaction.\n
-transaction = state_change[\'object\']\n
+            <value> <string>transaction = state_change[\'object\']\n
 \n
 # Get sections.\n
 source_section = transaction.getSourceSection()\n
@@ -77,19 +76,22 @@ destination_section = transaction.getDestinationSection()\n
 \n
 # Invoice Reference is automatically filled only for Sale Invoice Transaction.\n
 if transaction.getPortalType() == \'Sale Invoice Transaction\':\n
-  if transaction.getReference() in (None, \'\'):\n
+  if not transaction.getReference():\n
     invoice_id_group = (\'accounting\', \'invoice\', source_section)\n
-    invoice_reference = transaction.generateNewId(id_group = invoice_id_group)\n
+    invoice_reference = transaction.generateNewId(id_group=invoice_id_group,\n
+                                                  default=1)\n
     transaction.setReference(invoice_reference)\n
 \n
 # Generate new values for Source Reference and Destination Reference.\n
-if transaction.getSourceReference() in (None, \'\'):\n
+if not transaction.getSourceReference():\n
   source_id_group = (\'accounting\', \'section\', source_section)\n
-  source_reference = transaction.generateNewId(id_group = source_id_group)\n
+  source_reference = transaction.generateNewId(id_group=source_id_group,\n
+                                               default=1)\n
   transaction.setSourceReference(source_reference)\n
-if transaction.getDestinationReference() in (None, \'\'):\n
+if not transaction.getDestinationReference():\n
   destination_id_group = (\'accounting\', \'section\', destination_section)\n
-  destination_reference = transaction.generateNewId(id_group = destination_id_group)\n
+  destination_reference = transaction.generateNewId(\n
+                              id_group=destination_id_group, default=1)\n
   transaction.setDestinationReference(destination_reference)\n
 </string> </value>
         </item>
@@ -145,7 +147,6 @@ if transaction.getDestinationReference() in (None, \'\'):\n
                             <string>_getattr_</string>
                             <string>source_section</string>
                             <string>destination_section</string>
-                            <string>None</string>
                             <string>invoice_id_group</string>
                             <string>invoice_reference</string>
                             <string>source_id_group</string>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index e8930b6df9..55f04f2ae2 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-364
\ No newline at end of file
+365
\ No newline at end of file
-- 
2.30.9