details:   https://code.openbravo.com/erp/devel/main/rev/7111cfd6f97b
changeset: 21066:7111cfd6f97b
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Wed Sep 04 14:01:08 2013 +0200
summary:   fixed bug 24689: incorrect org filter in characteristics pop up

diffstat:

 src/org/openbravo/materialmgmt/ProductCharacteristicsDS.java |  21 ++++++++++-
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 094d0ead7ef5 -r 7111cfd6f97b 
src/org/openbravo/materialmgmt/ProductCharacteristicsDS.java
--- a/src/org/openbravo/materialmgmt/ProductCharacteristicsDS.java      Thu Sep 
05 06:26:38 2013 +0000
+++ b/src/org/openbravo/materialmgmt/ProductCharacteristicsDS.java      Wed Sep 
04 14:01:08 2013 +0200
@@ -19,14 +19,19 @@
 
 package org.openbravo.materialmgmt;
 
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.Query;
+import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.access.Role;
+import org.openbravo.model.ad.access.RoleOrganization;
 import org.openbravo.service.datasource.DefaultDataSourceService;
 import org.openbravo.service.json.JsonConstants;
 import org.openbravo.service.json.JsonUtils;
@@ -130,9 +135,19 @@
 
   private String getClientOrgFilter() {
     String clientId = OBContext.getOBContext().getCurrentClient().getId();
-    String orgId = OBContext.getOBContext().getCurrentOrganization().getId();
-    final Set<String> orgs = 
OBContext.getOBContext().getOrganizationStructureProvider()
-        .getNaturalTree(orgId);
+    final Set<String> orgs = new HashSet<String>();
+    OrganizationStructureProvider orgStructure = OBContext.getOBContext()
+        .getOrganizationStructureProvider();
+
+    // Role in OBContext has not organization list initialized, force reload 
to attach to current
+    // DAL's session
+    Role currentRole = OBDal.getInstance().get(Role.class,
+        OBContext.getOBContext().getRole().getId());
+
+    // Adding organizations in the trees of all granted ones
+    for (RoleOrganization org : currentRole.getADRoleOrganizationList()) {
+      orgs.addAll(orgStructure.getNaturalTree((String) 
DalUtil.getId(org.getOrganization())));
+    }
 
     StringBuilder hqlBuilder = new StringBuilder();
     hqlBuilder.append(" and c.client.id = '" + clientId + "' ");

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to