Commit 3694254d authored by Mark Orlando Molina's avatar Mark Orlando Molina Committed by Víctor Martínez Romanos
Browse files

Fixes ISSUE-46178: Ask if exists an org with GL configured instead of iterate all the existing ones

when filling session

Before trying to iterate throught all the organizations checking general ledger configuration, verify that
any of them has the configuration
parent ff9f7681
* Copyright (C) 2001-2019 Openbravo S.L.U.
* Copyright (C) 2001-2021 Openbravo S.L.U.
* Licensed under the Apache Software License version 2.0
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software distributed
......@@ -26,12 +26,14 @@ import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.criterion.Restrictions;
import org.openbravo.authentication.hashing.PasswordHash;
import org.openbravo.base.HttpBaseUtils;
import org.openbravo.base.exception.OBException;
import org.openbravo.base.exception.OBSecurityException;
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.XMLUtil;
......@@ -48,6 +50,7 @@ import;
import org.openbravo.model.common.enterprise.Organization;
import org.openbravo.service.db.DalConnectionProvider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
......@@ -298,7 +301,8 @@ public class LoginUtils {
// Get General Ledger of context organizations
if (ArrayUtils.isEmpty(attr)) {
// Before going for all organizations, check if any org has an accounting schema
if (ArrayUtils.isEmpty(attr) && existsOrgWithledgerConfigured()) {
String[] orgList = Utility.getContext(conn, vars, "#User_Org", "LoginHandler")
.replace("'", "")
......@@ -417,6 +421,16 @@ public class LoginUtils {
return true;
private static boolean existsOrgWithledgerConfigured() {
OBCriteria<Organization> orgCriteria = OBDal.getInstance().createCriteria(Organization.class);
return orgCriteria.uniqueResult() != null;
* Obtains defaults defined for a user and throws DefaultValidationException in case they are not
* correct.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment