details: https://code.openbravo.com/erp/devel/pi/rev/e6738814dcbe changeset: 32551:e6738814dcbe user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Wed Aug 09 15:24:46 2017 +0200 summary: related to bug 36628: can't update organization if entity has computed columns
Added test case details: https://code.openbravo.com/erp/devel/pi/rev/79642582d449 changeset: 32552:79642582d449 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Wed Aug 09 15:27:55 2017 +0200 summary: fixed bug 36628: can't update organization if entity has computed columns Computed columns organization matches base object's organization, when org in base one is updated, the one in computed columns does not. When validating referenced organizations computed columns was included, failing in this case. As computed is a virtual entity which client and org properties are just for convenience and they cannot be updated, it is not necessary to check for organization correctness. diffstat: src-test/src/org/openbravo/test/security/EntityAccessTest.java | 24 +++++++++- src/org/openbravo/dal/core/OBInterceptor.java | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diffs (60 lines): diff -r 31583e78ae29 -r 79642582d449 src-test/src/org/openbravo/test/security/EntityAccessTest.java --- a/src-test/src/org/openbravo/test/security/EntityAccessTest.java Wed Aug 09 11:02:37 2017 +0530 +++ b/src-test/src/org/openbravo/test/security/EntityAccessTest.java Wed Aug 09 15:27:55 2017 +0200 @@ -38,9 +38,12 @@ import org.openbravo.dal.security.EntityAccessChecker; import org.openbravo.dal.service.OBCriteria; import org.openbravo.dal.service.OBDal; +import org.openbravo.model.common.businesspartner.BusinessPartner; import org.openbravo.model.common.currency.Currency; import org.openbravo.model.common.currency.CurrencyTrl; -import org.openbravo.test.base.OBBaseTest; +import org.openbravo.model.common.enterprise.Organization; +import org.openbravo.model.common.enterprise.Warehouse; +import org.openbravo.model.common.order.Order; /** * Tests access on the basis of window and table definitions. Also tests derived read access. @@ -54,7 +57,7 @@ */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class EntityAccessTest extends OBBaseTest { +public class EntityAccessTest extends CrossOrganizationReference { private static final Logger log = Logger.getLogger(EntityAccessTest.class); @@ -212,4 +215,21 @@ assertEquals(1, cs.size()); OBDal.getInstance().remove(cs.get(0)); } + + /** Covers issue #36628: it was not possible to update organization if entity had computed columns */ + @Test + public void changeOrgIsAllowedHavingComputedColumns() { + setTestAdminContext(); + Order order = createOrder(SPAIN_ORG); + String orderId = order.getId(); + + // reload it from DB so that computed columns property is not null + OBDal.getInstance().getSession().evict(order); + order = OBDal.getInstance().get(Order.class, orderId); + + order.setOrganization(OBDal.getInstance().getProxy(Organization.class, USA_ORG)); + order.setWarehouse(OBDal.getInstance().getProxy(Warehouse.class, USA_WAREHOUSE)); + order.setBusinessPartner(OBDal.getInstance().getProxy(BusinessPartner.class, USA_BP)); + OBDal.getInstance().flush(); + } } \ No newline at end of file diff -r 31583e78ae29 -r 79642582d449 src/org/openbravo/dal/core/OBInterceptor.java --- a/src/org/openbravo/dal/core/OBInterceptor.java Wed Aug 09 11:02:37 2017 +0530 +++ b/src/org/openbravo/dal/core/OBInterceptor.java Wed Aug 09 15:27:55 2017 +0200 @@ -304,6 +304,7 @@ && bob.getEntity().getProperty(propertyNames[i]).isAllowedCrossOrgReference(); if (!skipCrossOrgCheck + && !obObject.getEntity().isVirtualEntity() && !obContext.getOrganizationStructureProvider(o1.getClient().getId()).isInNaturalTree( o1, o2)) { throw new OBSecurityException("Entity " + bob.getIdentifier() + " (" ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits