details: https://code.openbravo.com/erp/devel/pi/rev/e1053e861351 changeset: 29571:e1053e861351 user: Sanjota <sanjota.nelagi <at> promantia.com> date: Wed Jun 01 18:31:21 2016 +0530 summary: Fixes issue 33040: Accounting info not loaded when login
Unhomogeneous behavior depending on Org Access when role is defined at "Organization" user level. Accounting info was not loaded when login with a role without access to any general ledger's organization. details: https://code.openbravo.com/erp/devel/pi/rev/c265570e1b9d changeset: 29572:c265570e1b9d user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Thu Jun 02 12:51:40 2016 +0200 summary: Related to issue 33040: Code review improvements diffstat: src/org/openbravo/base/secureApp/Attribute_data.xsql | 17 ++++++++++++++++- src/org/openbravo/base/secureApp/LoginUtils.java | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diffs (77 lines): diff -r 7566dceb3847 -r c265570e1b9d src/org/openbravo/base/secureApp/Attribute_data.xsql --- a/src/org/openbravo/base/secureApp/Attribute_data.xsql Thu Jun 02 10:00:49 2016 +0200 +++ b/src/org/openbravo/base/secureApp/Attribute_data.xsql Thu Jun 02 12:51:40 2016 +0200 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!-- ************************************************************************************ - * Copyright (C) 2001-2011 Openbravo S.L.U. + * Copyright (C) 2001-2016 Openbravo S.L.U. * Licensed under the Apache Software License version 2.0 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed @@ -29,6 +29,21 @@ <Parameter name="clientlist" optional="true" type="replace" after="AND a.AD_CLIENT_ID IN (" text="'1'"/> <Parameter name="orglist" optional="true" type="replace" after="AND a.AD_ORG_ID IN (" text="'1'"/> </SqlMethod> + <SqlMethod name="selectAcctSchema" type="preparedStatement" return="multiple"> + <SqlMethodComment></SqlMethodComment> + <Sql><![CDATA[ + SELECT a.C_ACCTSCHEMA_ID as VALUE, a.C_CURRENCY_ID as Attribute, a.HASALIAS, + ae.ELEMENTTYPE, '' as AD_Window_ID, '' as C_CURRENCY_ID + FROM C_AcctSchema a + JOIN C_AcctSchema_Element ae + ON a.C_AcctSchema_ID=ae.C_ACCTSCHEMA_ID + WHERE a.C_AcctSchema_ID = ? + AND a.AD_CLIENT_ID IN ('1') + AND ae.ISACTIVE = 'Y' + ]]></Sql> + <Parameter name="acctId"/> + <Parameter name="clientlist" optional="true" type="replace" after="AND a.AD_CLIENT_ID IN (" text="'1'"/> + </SqlMethod> <SqlMethod name="selectIsSOTrx" type="preparedStatement" return="multiple"> <SqlMethodComment></SqlMethodComment> <Sql> diff -r 7566dceb3847 -r c265570e1b9d src/org/openbravo/base/secureApp/LoginUtils.java --- a/src/org/openbravo/base/secureApp/LoginUtils.java Thu Jun 02 10:00:49 2016 +0200 +++ b/src/org/openbravo/base/secureApp/LoginUtils.java Thu Jun 02 12:51:40 2016 +0200 @@ -21,6 +21,8 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.openbravo.base.HttpBaseUtils; import org.openbravo.base.exception.OBException; @@ -32,6 +34,7 @@ import org.openbravo.erpCommon.businessUtility.Preferences; import org.openbravo.erpCommon.security.SessionLogin; import org.openbravo.erpCommon.utility.DimensionDisplayUtility; +import org.openbravo.erpCommon.utility.OBLedgerUtils; import org.openbravo.erpCommon.utility.PropertyException; import org.openbravo.erpCommon.utility.Utility; import org.openbravo.model.ad.access.RoleOrganization; @@ -273,9 +276,19 @@ vars.setSessionValue("#Client_SMTP", data[0].smtphost); data = null; - AttributeData[] attr = AttributeData.select(conn, - Utility.getContext(conn, vars, "#User_Client", "LoginHandler"), - Utility.getContext(conn, vars, "#User_Org", "LoginHandler")); + AttributeData[] attr = null; + String[] orgList = Utility.getContext(conn, vars, "#User_Org", "LoginHandler").split(","); + for (String orgId : orgList) { + String acctSchemaId = OBLedgerUtils.getOrgLedger(orgId.replace("'", "")); + if (StringUtils.isNotEmpty(acctSchemaId)) { + attr = AttributeData.selectAcctSchema(conn, acctSchemaId, + Utility.getContext(conn, vars, "#User_Client", "LoginHandler")); + if (ArrayUtils.isNotEmpty(attr)) { + break; + } + } + } + if (attr != null && attr.length > 0) { vars.setSessionValue("$C_AcctSchema_ID", attr[0].value); if (orgCurrency.length > 0) { ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits