details:   /erp/devel/pi/rev/b5d2077a283e
changeset: 7314:b5d2077a283e
user:      David Alsasua <david.alsasua <at> openbravo.com>
date:      Thu May 13 22:54:25 2010 +0530
summary:   Fixes issue 13234: Uncorrect Account Schema in combination

details:   /erp/devel/pi/rev/5c11c1f41fe4
changeset: 7315:5c11c1f41fe4
user:      David Alsasua <david.alsasua <at> openbravo.com>
date:      Thu May 13 22:54:51 2010 +0530
summary:   Merge

diffstat:

 build.xml                                                                  |   
 1 -
 src-db/database/lib/dbsourcemanager.jar                                    |   
 0 
 src-db/database/model/functions/C_INVOICE_CREATE.xml                       |   
13 +-
 src-db/database/sourcedata/AD_COLUMN.xml                                   |   
 1 +
 src-db/database/sourcedata/AD_REF_LIST.xml                                 |   
12 -
 src-db/database/sourcedata/AD_TEXTINTERFACES.xml                           |   
22 +
 src-test/org/openbravo/test/dal/IssuesTest.java                            |   
37 +
 src-test/org/openbravo/test/dal/OBContextTest.java                         |   
22 +-
 src-test/org/openbravo/test/dal/test_13281.xml                             |   
75 ++
 src/build.xml                                                              |   
20 +
 src/org/openbravo/base/secureApp/LoginUtils.java                           |   
 2 +-
 src/org/openbravo/dal/core/DalUtil.java                                    |   
20 +
 src/org/openbravo/dal/core/OBContext.java                                  |   
62 ++-
 src/org/openbravo/dal/xml/XMLEntityConverter.java                          |  
271 +++++----
 src/org/openbravo/erpCommon/ad_actionButton/CopyFromSettlement.java        |   
 4 +-
 src/org/openbravo/erpCommon/ad_forms/ModuleManagement_ErrorCommercial.html |   
 2 +-
 src/org/openbravo/erpCommon/ad_forms/TranslationHandler.java               |   
 7 +-
 src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java             |   
 4 +-
 src/org/openbravo/erpCommon/ad_reports/ReportTrialBalanceExcel.jrxml       |   
31 +-
 src/org/openbravo/erpCommon/ad_reports/ReportTrialBalancePDF.jrxml         |   
49 +-
 src/org/openbravo/erpCommon/modules/ImportModule.java                      |   
 6 +-
 src/org/openbravo/erpCommon/obps/ActivationKey.java                        |   
 3 +
 22 files changed, 471 insertions(+), 193 deletions(-)

diffs (truncated from 1177 to 300 lines):

diff -r 8e9227c2cd5b -r 5c11c1f41fe4 build.xml
--- a/build.xml Mon May 10 13:27:56 2010 +0200
+++ b/build.xml Thu May 13 22:54:51 2010 +0530
@@ -68,7 +68,6 @@
   <property name="base.src.trl" location="src-trl" />
   <property name="base.src.wad" location="src-wad" />
   <property name="base.src.gen" location="src-gen" />
-  <property name="base.src.test" location="src-test" />
   <property name="base.client.src" location="srcClient" />
   <property name="base.db" location="src-db/database" />
   <property name="base.web" location="web" />
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 src-db/database/lib/dbsourcemanager.jar
Binary file src-db/database/lib/dbsourcemanager.jar has changed
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 
src-db/database/model/functions/C_INVOICE_CREATE.xml
--- a/src-db/database/model/functions/C_INVOICE_CREATE.xml      Mon May 10 
13:27:56 2010 +0200
+++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml      Thu May 13 
22:54:51 2010 +0530
@@ -378,6 +378,7 @@
               */
               -- Get Order DocType Info - approved from Invoice DocType
               BEGIN
+              v_DocType_ID:=NULL;
               v_ResultStr:='GetDocTypeInfo - ' || Cur_Order.C_DocType_ID;  
SELECT od.C_DocTypeInvoice_ID,
                 od.DocSubTypeSO
               INTO v_DocType_ID,
@@ -389,8 +390,11 @@
                 AND ID.IsActive='Y';
               EXCEPTION
               WHEN OTHERS THEN
+                v_DocType_ID:=NULL;
+              END;
+              IF (v_DocType_ID IS NULL) THEN
                 RAISE_APPLICATION_ERROR(-20000, '@NoDocumentTypeFound@') ;
-              END;
+              END IF;
               --
               Ad_Sequence_Next('C_Invoice', Cur_Order.AD_Client_ID, 
p_Invoice_ID) ;
               Ad_Sequence_Doctype(v_DocType_ID, Cur_Order.AD_Client_ID, 'Y', 
v_DocumentNo) ;
@@ -902,6 +906,7 @@
                   END;
                 ELSE
                   BEGIN
+                  v_DocType_ID:=NULL;
                   SELECT od.C_DocTypeInvoice_ID
                   INTO v_DocType_ID
                   FROM C_DOCTYPE od,
@@ -913,8 +918,12 @@
                     AND ID.IsActive='Y';
                   EXCEPTION
                   WHEN OTHERS THEN
+                    v_DocType_ID:=NULL;
+                  END;
+                  IF (v_DocType_ID IS NULL) THEN
                     RAISE_APPLICATION_ERROR(-20000, '@NoDocumentTypeFound@') ;
-                  END;
+                  END IF;
+
                 END IF;
                 IF(NOT FINISH_PROCESS) THEN
                   -- Get other defaults
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 src-db/database/sourcedata/AD_COLUMN.xml
--- a/src-db/database/sourcedata/AD_COLUMN.xml  Mon May 10 13:27:56 2010 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml  Thu May 13 22:54:51 2010 +0530
@@ -24481,6 +24481,7 @@
 <!--1632-->  <COLUMNNAME><![CDATA[C_AcctSchema_ID]]></COLUMNNAME>
 <!--1632-->  <AD_TABLE_ID><![CDATA[224]]></AD_TABLE_ID>
 <!--1632-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--1632-->  
<AD_VAL_RULE_ID><![CDATA[7BAD557A87B64D5386215D77F79A43D7]]></AD_VAL_RULE_ID>
 <!--1632-->  <FIELDLENGTH><![CDATA[22]]></FIELDLENGTH>
 <!--1632-->  <DEFAULTVALUE><![cda...@$c_acctschema_id@]]></DEFAULTVALUE>
 <!--1632-->  <ISKEY><![CDATA[N]]></ISKEY>
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/sourcedata/AD_REF_LIST.xml        Mon May 10 13:27:56 
2010 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml        Thu May 13 22:54:51 
2010 +0530
@@ -9922,18 +9922,6 @@
 <!--D832F22185A0419F875AF44B6E68A2B1-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--D832F22185A0419F875AF44B6E68A2B1--></AD_REF_LIST>
 
-<!--D888722E702B46E1B781AEE4FF1CA610--><AD_REF_LIST>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  
<AD_REF_LIST_ID><![CDATA[D888722E702B46E1B781AEE4FF1CA610]]></AD_REF_LIST_ID>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  <VALUE><![CDATA[LoginPage]]></VALUE>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  <NAME><![CDATA[Page showing the login 
dialog]]></NAME>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  <DESCRIPTION><![CDATA[The page which 
allows a user to login into the application.]]></DESCRIPTION>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  
<AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
-<!--D888722E702B46E1B781AEE4FF1CA610-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--D888722E702B46E1B781AEE4FF1CA610--></AD_REF_LIST>
-
 <!--DAC02370F50D485BAA4F79957AA1A7A4--><AD_REF_LIST>
 <!--DAC02370F50D485BAA4F79957AA1A7A4-->  
<AD_REF_LIST_ID><![CDATA[DAC02370F50D485BAA4F79957AA1A7A4]]></AD_REF_LIST_ID>
 <!--DAC02370F50D485BAA4F79957AA1A7A4-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 
src-db/database/sourcedata/AD_TEXTINTERFACES.xml
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml  Mon May 10 13:27:56 
2010 +0200
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml  Thu May 13 22:54:51 
2010 +0530
@@ -17231,6 +17231,17 @@
 <!--55CB1D49B2F44246A6D4BFDA6B262B36-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--55CB1D49B2F44246A6D4BFDA6B262B36--></AD_TEXTINTERFACES>
 
+<!--565C74A29CF54C7D8F86A451FC3BB2AF--><AD_TEXTINTERFACES>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  
<AD_TEXTINTERFACES_ID><![CDATA[565C74A29CF54C7D8F86A451FC3BB2AF]]></AD_TEXTINTERFACES_ID>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  <TEXT><![CDATA[Trial Balance 
Report]]></TEXT>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  
<FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/ReportTrialBalancePDF.jrxml]]></FILENAME>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--565C74A29CF54C7D8F86A451FC3BB2AF--></AD_TEXTINTERFACES>
+
 <!--5672EC35714493E8E040A8C0546675F1--><AD_TEXTINTERFACES>
 <!--5672EC35714493E8E040A8C0546675F1-->  
<AD_TEXTINTERFACES_ID><![CDATA[5672EC35714493E8E040A8C0546675F1]]></AD_TEXTINTERFACES_ID>
 <!--5672EC35714493E8E040A8C0546675F1-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -20476,6 +20487,17 @@
 <!--7114FE4C0B1B4FDA8ED139023D9749BA-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--7114FE4C0B1B4FDA8ED139023D9749BA--></AD_TEXTINTERFACES>
 
+<!--745BED8287B445A4A7E6D7ABEFB14951--><AD_TEXTINTERFACES>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  
<AD_TEXTINTERFACES_ID><![CDATA[745BED8287B445A4A7E6D7ABEFB14951]]></AD_TEXTINTERFACES_ID>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  <TEXT><![CDATA[Trial Balance 
Report]]></TEXT>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  
<FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/ReportTrialBalanceExcel.jrxml]]></FILENAME>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--745BED8287B445A4A7E6D7ABEFB14951-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--745BED8287B445A4A7E6D7ABEFB14951--></AD_TEXTINTERFACES>
+
 <!--755436B125F81A5AE040007F010176A4--><AD_TEXTINTERFACES>
 <!--755436B125F81A5AE040007F010176A4-->  
<AD_TEXTINTERFACES_ID><![CDATA[755436B125F81A5AE040007F010176A4]]></AD_TEXTINTERFACES_ID>
 <!--755436B125F81A5AE040007F010176A4-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 
src-test/org/openbravo/test/dal/IssuesTest.java
--- a/src-test/org/openbravo/test/dal/IssuesTest.java   Mon May 10 13:27:56 
2010 +0200
+++ b/src-test/org/openbravo/test/dal/IssuesTest.java   Thu May 13 22:54:51 
2010 +0530
@@ -27,15 +27,19 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.model.Reference;
 import org.openbravo.base.model.domaintype.LongDomainType;
 import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.structure.IdentifierProvider;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
+import org.openbravo.dal.xml.XMLEntityConverter;
 import org.openbravo.data.UtilSql;
 import org.openbravo.model.ad.access.Role;
 import org.openbravo.model.ad.access.User;
@@ -91,6 +95,12 @@
  * - https://issues.openbravo.com/view.php?id=13136: OBContext.getLanguage 
does only use users'
  * default language, and does not honor language change in the role change 
popup
  * 
+ * - https://issues.openbravo.com/view.php?id=13281: [REST] when inserting an 
object through REST
+ * allow setting the organization through xml
+ * 
+ * https://issues.openbravo.com/view.php?id=13283: [REST] use organization of 
the object to
+ * retrieved referenced objects
+ * 
  * @author mtaal
  * @author iperdomo
  */
@@ -396,4 +406,31 @@
     OBContext.setOBContext("100", "0", "0", "0", "en_IN");
     assertEquals("130", OBContext.getOBContext().getLanguage().getId());
   }
+
+  /**
+   * https://issues.openbravo.com/view.php?id=13281 [REST] when inserting an 
object through REST
+   * allow setting the organization through xml
+   * 
+   * https://issues.openbravo.com/view.php?id=13283: [REST] use organization 
of the object to
+   * retrieved referenced objects
+   */
+  public void test13281And13283() throws Exception {
+    OBContext.setOBContext("1000000", "1000004", "1000000", "0");
+
+    // use the same logic as in the DalWebService
+    final XMLEntityConverter xec = XMLEntityConverter.newInstance();
+    xec.setClient(OBContext.getOBContext().getCurrentClient());
+    xec.setOrganization(OBContext.getOBContext().getCurrentOrganization());
+
+    // for a webservice referenced entities should not be created at all!
+    xec.getEntityResolver().setOptionCreateReferencedIfNotFound(false);
+
+    final SAXReader reader = new SAXReader();
+    final Document document = 
reader.read(this.getClass().getResourceAsStream("test_13281.xml"));
+    final List<BaseOBObject> result = xec.process(document);
+    assertTrue(result.size() == 1);
+    assertTrue(result.get(0) instanceof Order);
+    final Order order = (Order) result.get(0);
+    assertTrue(order.getOrganization().getId().equals("1000000"));
+  }
 }
\ No newline at end of file
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 
src-test/org/openbravo/test/dal/OBContextTest.java
--- a/src-test/org/openbravo/test/dal/OBContextTest.java        Mon May 10 
13:27:56 2010 +0200
+++ b/src-test/org/openbravo/test/dal/OBContextTest.java        Thu May 13 
22:54:51 2010 +0530
@@ -31,9 +31,17 @@
 public class OBContextTest extends BaseTest {
 
   /**
-   * Tests if the {...@link OBContext#setAdminMode()} and
-   * {...@link OBContext#restorePreviousMode()} work correctly if the same 
OBContext is used by
-   * multiple threads. This is possible in case of simultaneous ajax requests.
+   * Tests if the warehouse is set correctly in the OBContext.
+   */
+  public void testWarehouseInContext() {
+    OBContext.setOBContext("100", "0", "1000000", "1000000", null, "1000001");
+    
assertTrue(OBContext.getOBContext().getWarehouse().getId().equals("1000001"));
+  }
+
+  /**
+   * Tests if the {...@link OBContext#setAdminMode()} and {...@link 
OBContext#restorePreviousMode()} work
+   * correctly if the same OBContext is used by multiple threads. This is 
possible in case of
+   * simultaneous ajax requests.
    * 
    * See: https://issues.openbravo.com/view.php?id=8853
    */
@@ -177,10 +185,6 @@
       }
     }
 
-    public boolean isNextStep() {
-      return nextStep;
-    }
-
     public void setNextStep(boolean nextStep) {
       this.nextStep = nextStep;
     }
@@ -189,10 +193,6 @@
       return adminMode;
     }
 
-    public boolean isFirstStep() {
-      return firstStep;
-    }
-
     public void setFirstStep(boolean firstStep) {
       this.firstStep = firstStep;
     }
diff -r 8e9227c2cd5b -r 5c11c1f41fe4 
src-test/org/openbravo/test/dal/test_13281.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/dal/test_13281.xml    Thu May 13 22:54:51 
2010 +0530
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ob:Openbravo xmlns:ob="http://www.openbravo.com";>
+<Order>
+<client id="1000000" entity-name="ADClient" identifier="SmallBazaar"/>
+<organization id="1000000" entity-name="Organization" identifier="Main"/>
+<active>true</active>
+<creationDate transient="true">2010-05-07T20:40:25.129Z</creationDate>
+<createdBy transient="true" id="100" entity-name="ADUser" 
identifier="Openbravo"/>
+<updated transient="true">2010-05-10T20:48:32.936Z</updated>
+<updatedBy transient="true" id="100" entity-name="ADUser" 
identifier="Openbravo"/>
+<salesTransaction>true</salesTransaction>
+<documentNo>50042</documentNo>
+<documentStatus>DR</documentStatus>
+<documentAction>CO</documentAction>
+<processNow>false</processNow>
+<processed>false</processed>
+<documentType id="0" entity-name="DocumentType" identifier="** New **"/>
+<transactionDocument id="1000026" entity-name="DocumentType" 
identifier="Standard Order"/>
+<description>descripcionnnnn</description>
+<delivered>false</delivered>
+<reinvoice>false</reinvoice>
+<print>false</print>
+<selected>false</selected>
+<salesRepresentative id="1000013" entity-name="ADUser" identifier="Our Sales 
Agent"/>
+<orderDate>2010-05-07T00:00:00.0Z</orderDate>
+<scheduledDeliveryDate>2010-05-07T00:00:00.0Z</scheduledDeliveryDate>
+<datePrinted></datePrinted>
+<accountingDate>2010-05-07T00:00:00.0Z</accountingDate>
+<businessPartner id="1000004" entity-name="BusinessPartner" identifier="The 
Simpsons Ltd"/>
+<invoiceAddress id="1000001" entity-name="BusinessPartnerLocation" 
identifier=".Springfield, Avenida Evergreen Terrace 742"/>
+<partnerAddress id="1000001" entity-name="BusinessPartnerLocation" 
identifier=".Springfield, Avenida Evergreen Terrace 742"/>
+<orderReference></orderReference>
+<printDiscount>false</printDiscount>
+<currency id="102" entity-name="Currency" identifier="EUR"/>
+<formOfPayment>1</formOfPayment>
+<paymentTerms id="1000000" entity-name="FinancialMgmtPaymentTerm" 
identifier="Immediate"/>
+<invoiceTerms>S</invoiceTerms>
+<deliveryTerms>A</deliveryTerms>
+<freightCostRule>I</freightCostRule>
+<freightAmount>0.00</freightAmount>
+<deliveryMethod>S</deliveryMethod>
+<shippingCompany></shippingCompany>
+<charge></charge>
+<chargeAmount>0.00</chargeAmount>
+<priority>5</priority>
+<summedLineAmount>0.00</summedLineAmount>
+<grandTotalAmount>0.00</grandTotalAmount>
+<warehouse id="1000000" entity-name="Warehouse" identifier="Main Warehouse"/>
+<priceList id="1000005" entity-name="PricingPriceList"/>
+<priceIncludesTax>false</priceIncludesTax>

------------------------------------------------------------------------------

_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to