details:   https://code.openbravo.com/erp/devel/pi/rev/9388451efb97
changeset: 30300:9388451efb97
user:      Mark <markmm82 <at> gmail.com>
date:      Mon Sep 19 11:33:17 2016 -0400
summary:   Fixes issue 34018: Is possible posting a Purchase Invoice with 
Finance role

Modified the 
OrganizationStructureProvider.getPeriodControlAllowedOrganization() method to 
execute in Admin mode.

diffstat:

 src/org/openbravo/dal/security/OrganizationStructureProvider.java |  24 
++++++---
 1 files changed, 15 insertions(+), 9 deletions(-)

diffs (35 lines):

diff -r 9fe27cd2151e -r 9388451efb97 
src/org/openbravo/dal/security/OrganizationStructureProvider.java
--- a/src/org/openbravo/dal/security/OrganizationStructureProvider.java Mon Sep 
19 14:24:57 2016 +0000
+++ b/src/org/openbravo/dal/security/OrganizationStructureProvider.java Mon Sep 
19 11:33:17 2016 -0400
@@ -465,15 +465,21 @@
    *          Organization to get its period control allowed organization.
    */
   public Organization getPeriodControlAllowedOrganization(final Organization 
org) {
-    if (org.isAllowPeriodControl()) {
-      return org;
+    // Admin mode needed to get the Organization type.
+    OBContext.setAdminMode(true);
+    try {
+      if (org.isAllowPeriodControl()) {
+        return org;
+      }
+      for (final String orgId : getParentList(org.getId(), false)) {
+        final Organization parentOrg = 
OBDal.getInstance().get(Organization.class, orgId);
+        if (parentOrg.isAllowPeriodControl()) {
+          return parentOrg;
+        }
+      }
+      return null;
+    } finally {
+      OBContext.restorePreviousMode();
     }
-    for (final String orgId : getParentList(org.getId(), false)) {
-      final Organization parentOrg = 
OBDal.getInstance().get(Organization.class, orgId);
-      if (parentOrg.isAllowPeriodControl()) {
-        return parentOrg;
-      }
-    }
-    return null;
   }
 }
\ No newline at end of file

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to