Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0013281Openbravo ERPA. Platformpublic2010-05-11 06:492010-05-18 21:44
mtaal 
mtaal 
normalmajorhave not tried
closedfixed 
5
pi 
2.50MP17 
Core
No
0013281: [REST] when inserting an object through REST allow setting the organization through xml
When a new object is passed in through a POST REST request the client/org are always set to the current client/org of the user. This eventhough the xml may contain a valid organization (for the current client of the user and accessible for the user).

For example, for sales orders a user can choose the organization in the sales order entry. The same should be allowed through REST.
1) set the default role to Openbravo Admin but with organization 0 (*)
2) upload through REST (and a POST request) the attached order xml
3) you will get an error:
<ob:error xmlns:ob="http://www.openbravo.com"><message>org.openbravo.service.web.InvalidContentException: [^] Object Order(null) is new but not writable
Caused by: Object Order(null) is new but not writable</message></ob:error>
Allow setting the organization through REST if it is a valid/writable organization for the user.

Changes: see the XMLEntityConverter:
1) this has to be moved to after setting all many-to-one properties:


      if (!writable && bob.isNewOBObject()) {
        error("Object " + entityName + "(" + id + ") is new but not writable");
        return bob;
      }
2) This has to be changed to check if the org is a valid/writable org for the user:

          final boolean orgUpdate = bob instanceof OrganizationEnabled
              && p.getName().equals(Client.PROPERTY_ORGANIZATION);
          if (!isOptionClientImport() && currentValue != null && (clientUpdate || orgUpdate)) {
No tags attached.
related to defect 00132832.50MP17 closed mtaal [REST] use organization of the object to retrieved referenced objects 
xml rest_order.xml (3,282) 2010-05-11 06:49
https://issues.openbravo.com/file_download.php?file_id=2541&type=bug
Issue History
2010-05-11 06:49mtaalNew Issue
2010-05-11 06:49mtaalAssigned To => mtaal
2010-05-11 06:49mtaalFile Added: rest_order.xml
2010-05-11 07:47mtaalRelationship addedrelated to 0013283
2010-05-11 13:24hgbotCheckin
2010-05-11 13:24hgbotNote Added: 0027133
2010-05-11 13:24hgbotStatusnew => resolved
2010-05-11 13:24hgbotResolutionopen => fixed
2010-05-11 13:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b27cb4c80a74ce23b5d861cfc32f1313fefa2c7d [^]
2010-05-11 18:19jpabloaeTarget Version2.50MP16 => 2.50MP17
2010-05-14 19:02iperdomoNote Added: 0027322
2010-05-14 19:02iperdomoStatusresolved => closed
2010-05-15 00:01anonymoussf_bug_id0 => 3001864
2010-05-18 21:44hudsonbotCheckin
2010-05-18 21:44hudsonbotNote Added: 0027512

Notes
(0027133)
hgbot   
2010-05-11 13:24   
Repository: erp/devel/pi
Changeset: b27cb4c80a74ce23b5d861cfc32f1313fefa2c7d
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Tue May 11 13:23:41 2010 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/b27cb4c80a74ce23b5d861cfc32f1313fefa2c7d [^]

Fixes issue 13281: [REST] when inserting an object through REST allow setting the organization through xml
Fixes issue 13283: [REST] use organization of the object to retrieved referenced objects

---
M src-test/org/openbravo/test/dal/IssuesTest.java
M src/org/openbravo/dal/xml/XMLEntityConverter.java
A src-test/org/openbravo/test/dal/test_13281.xml
---
(0027322)
iperdomo   
2010-05-14 19:02   
Tested on PI @ rev. d58960feb659
(0027512)
hudsonbot   
2010-05-18 21:44   
A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/b27cb4c80a74 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/aa11838d5f80 [^]
Tests: http://builds.openbravo.com/view/devel-int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.17380.obx [^]