Openbravo Issue Tracking System - Openbravo ERP | ||||||||||||
View Issue Details | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | |||||||
0046217 | Openbravo ERP | A. Platform | public | 2021-04-06 13:47 | 2022-02-01 07:24 | |||||||
Reporter | vmromanos | |||||||||||
Assigned To | Triage Platform Base | |||||||||||
Priority | normal | Severity | minor | Reproducibility | always | |||||||
Status | new | Resolution | open | |||||||||
Platform | OS | 5 | OS Version | |||||||||
Product Version | ||||||||||||
Target Version | Fixed in Version | |||||||||||
Merge Request Status | ||||||||||||
Review Assigned To | ||||||||||||
OBNetwork customer | ||||||||||||
Web browser | ||||||||||||
Modules | Core | |||||||||||
Support ticket | ||||||||||||
Regression level | ||||||||||||
Regression date | ||||||||||||
Regression introduced in release | ||||||||||||
Regression introduced by commit | ||||||||||||
Triggers an Emergency Pack | No | |||||||||||
Summary | 0046217: Organization entity and OBCriteria.setFilterOnReadableOrganization(true) won't work | |||||||||||
Description | In OBCriteria.initialize() we have the following code: if (isFilterOnReadableOrganization() && e.isOrganizationPartOfKey()) { add(Restrictions.in("id." + PROPERTY_ORGANIZATION + ".id", (Object[]) obContext.getReadableOrganizations())); } else if (isFilterOnReadableOrganization() && e.isOrganizationEnabled()) { add(Restrictions.in(PROPERTY_ORGANIZATION + ".id", (Object[]) obContext.getReadableOrganizations())); } In order to add the readable organizations filter the entity should either isOrganizationPartOfKey() or isOrganizationEnabled(). Both methods depend on variables set at Property.initializeName() method: if (getName().equals("organization")) { setClientOrOrganization(true); getEntity().setOrganizationEnabled(true); if (isId() || isPartOfCompositeId()) { getEntity().setOrganizationPartOfKey(true); } } In the case of the Organization entity we don't have a property called "organization" because it's actually the entity's "id", so Organization is never set as organizationEnabled or organizationPartOfKey, so the OBCriteria never adds the filter over the readable organizations. Note this is a corner case that should only happen when querying the Organization entity using the OBCriteria. Any other entity should be safe. Right now any OBCriteria over the Organization entity doesn't add any filter to readable organizations, which means the query is run for every organization (unless the OBCriteria instance adds an explicit filter over the organization's ids). | |||||||||||
Steps To Reproduce | Create a simple OBCriteria over Organization entity. Example: OBCriteria<Organization> orgCriteria = OBDal.getInstance().createCriteria(Organization.class); orgCriteria.setMaxResults(1); orgCriteria.uniqueResult(); Set a breakpoint at OBCriteria.initialize() [in the above code]. Verify isFilterOnReadableOrganization() is true, but the Restriction over the readable organizations is not added. | |||||||||||
Proposed Solution | ||||||||||||
Additional Information | ||||||||||||
Tags | No tags attached. | |||||||||||
Relationships |
| |||||||||||
Attached Files | ||||||||||||
Issue History | ||||||||||||
Date Modified | Username | Field | Change | |||||||||
2021-04-06 13:47 | vmromanos | New Issue | ||||||||||
2021-04-06 13:47 | vmromanos | Assigned To | => platform | |||||||||
2021-04-06 13:47 | vmromanos | Modules | => Core | |||||||||
2021-04-06 13:47 | vmromanos | Triggers an Emergency Pack | => No | |||||||||
2021-04-06 14:24 | vmromanos | Relationship added | related to 0046178 | |||||||||
2022-02-01 07:24 | alostale | Assigned To | platform => Triage Platform Base |
There are no notes attached to this issue. |