Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036598Openbravo ERPA. Platformpublic2017-08-04 09:352017-09-21 16:49
vmromanos 
inigosanchez 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q43.0PR17Q4 
caristu
Core
No
0036598: Process Definition for multirecord sets only one organization in filter parameters
A Process Definition is defined to work with multirecords. In this case you can select records belonging to different organizations.
However, when the records are submitted to the server, a unique parameter "_org=" is sent as filter. Then the server detects it and tries to get the natural tree for this organization.
When you have selected records belonging to different trees, the records belonging to a different natural tree of the "_org" parameter are filtered out.
Create a Process Definition for multirecord and standard ui.
Add a grid that shows Sales Invoices
Create a button in Sales Invoice window and link it to the process definition

In the onload function for the Process Definition add a similar code, replacing the necessary lines (mainly function name and grid name):

OB.OBAWO.onLoad = function (view) {
  var selection, paramGrid, parentGrid, criteria, gridCriteria;

  parentGrid = view.parentWindow.view.viewGrid;
  selection = parentGrid.getSelectedRecords();
  paramGrid = view.theForm.getItem('stock').canvas.viewGrid;

  criteria = [];
  selection.forEach(function (r) {
    criteria.push({
      fieldName: 'id',
      operator: 'equals',
      value: r.id
    });
  });
  gridCriteria = {
          operator: 'or',
    _constructor: 'AdvancedCriteria',
    criteria: criteria
  };

  paramGrid.dataSource.requestProperties.params.criteria = gridCriteria;
  
};


The idea is to select some records in Sales Invoice window, press the Process Definition button, and display only those records in the new popup grid.


In Sales Invoice window select 2 records, one for Norte and the other for Sur. Press the Process Definition button.
Verify just one record is shown.
Close the popup.

Repeat the selection, but this time selecting several records from the same org.
Verify all the records are now shown in the new grid.



Set a break point in AdvancedQueryBuilder.java, addWhereOrgParameters method.
And repeat the process.
Verify filterparameters contains a parameter _org with any of the organizations, that is used to add the natural tree filter. Example (in my case I work with storage details):

{@MaterialMgmtStorageDetail.storageBin@=4B413455BCE541C0AB80E18BFD7247B5, @MaterialMgmtStorageDetail.client@=A64C68776B544B0DB59C16456C43E608, @MaterialMgmtStorageDetail.product@=110D54D3A4214D3095008EC8F35D88B5, @MaterialMgmtStorageDetail.id@=DBB2E952074E47A5B4377B4115F03F02, whereAndFilterClause=e.qtyPutAway>0, @MaterialMgmtStorageDetail.organization@=3FF21930C89F4A8FAC60E7264BF96568, @MaterialMgmtStorageDetail.uOM@=100, _org=3FF21930C89F4A8FAC60E7264BF96568, @MaterialMgmtStorageDetail.attributeSetValue@=0}
When selecting multiple records, it would be better to set the JsonConstants.CALCULATE_ORGS parameter instead so we enter by the second if:

    if (filterParameters.containsKey(JsonConstants.ORG_PARAMETER)) {
      final String value = filterParameters.get(JsonConstants.ORG_PARAMETER);
      if (entity.isOrganizationEnabled() && value != null && value.length() > 0) {
        orgs = OBContext.getOBContext().getOrganizationStructureProvider().getNaturalTree(value);
        orgPart = buildOrgPartWhereClause(orgs);
      }
      localWhereClause = buildLocalWhereClause(localWhereClause, orgPart);
    } else if (filterParameters.containsKey(JsonConstants.CALCULATE_ORGS)) {
      // add natural tree of writable organizations
      final Set<String> orgsWritables = OBContext.getOBContext().getWritableOrganizations();
      for (final String o : orgsWritables) {
        orgs.addAll(OBContext.getOBContext().getOrganizationStructureProvider().getNaturalTree(o));
      }
      orgPart = buildOrgPartWhereClause(orgs);
      localWhereClause = buildLocalWhereClause(localWhereClause, orgPart);
    }
No tags attached.
related to defect 0036151 closed caristu organization selector in process definition don't filter by role's org access 
related to defect 0035124 closed inigosanchez Selectors in Process Definition invoked from menu show only records of organizations in the context organization's natural tree 
Issue History
2017-08-04 09:35vmromanosNew Issue
2017-08-04 09:35vmromanosAssigned To => platform
2017-08-04 09:35vmromanosModules => Core
2017-08-04 09:35vmromanosTriggers an Emergency Pack => No
2017-08-04 09:36vmromanosSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15592#r15592
2017-08-04 09:36vmromanosProposed Solution updated
2017-08-04 09:46alostalePriorityhigh => urgent
2017-08-04 09:46alostaleStatusnew => acknowledged
2017-08-10 10:21alostaleRelationship addedrelated to 0036151
2017-08-18 13:56inigosanchezAssigned Toplatform => inigosanchez
2017-08-18 13:56inigosanchezStatusacknowledged => scheduled
2017-08-18 13:56inigosanchezStatusscheduled => feedback
2017-08-24 13:46inigosanchezStatusfeedback => scheduled
2017-08-30 12:50inigosanchezRelationship addedrelated to 0035124
2017-08-31 11:24hgbotCheckin
2017-08-31 11:24hgbotNote Added: 0098749
2017-08-31 11:24hgbotStatusscheduled => resolved
2017-08-31 11:24hgbotResolutionopen => fixed
2017-08-31 11:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/74017a22fc13565b4f2988a87fffc17fae151cf6 [^]
2017-08-31 11:26inigosanchezReview Assigned To => alostale
2017-09-01 09:09alostaleNote Added: 0098768
2017-09-01 09:09alostaleStatusresolved => new
2017-09-01 09:09alostaleResolutionfixed => open
2017-09-01 10:27inigosanchezStatusnew => scheduled
2017-09-04 10:01hgbotCheckin
2017-09-04 10:01hgbotNote Added: 0098792
2017-09-04 10:02inigosanchezStatusscheduled => resolved
2017-09-04 10:02inigosanchezFixed in Version => 3.0PR17Q4
2017-09-04 10:02inigosanchezResolutionopen => fixed
2017-09-11 17:13caristuReview Assigned Toalostale => caristu
2017-09-18 12:20caristuNote Added: 0099103
2017-09-18 12:20caristuStatusresolved => closed
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099350
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099353

Notes
(0098749)
hgbot   
2017-08-31 11:24   
Repository: erp/devel/pi
Changeset: 74017a22fc13565b4f2988a87fffc17fae151cf6
Author: Inigo Sanchez <inigo.sanchez <at> openbravo.com>
Date: Thu Aug 31 11:22:01 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/74017a22fc13565b4f2988a87fffc17fae151cf6 [^]

Fixed issue 36598: Multirecord Process sets only one organization in parameters

A standard process can be defined as multi record process to be able to execute it for more than one
record. In this case it can be selected records belonging to different organizations. The reported
problem was that in this situation it was take into account only the first organization sending it
as "_org" parameter.


This problem has been fixed by managing this situation properly. Now, when a multirecord process is
launched and more than one record is selected, the natural tree of writable organizations of the
current context is calculated instead of the natural tree of the first organization of the first
selected record.

---
M modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
---
(0098768)
alostale   
2017-09-01 09:09   
Working correctly for grids shown in P&E, but to be consistent the same behavior should also apply to selector fields in P&E. Note this is already implemented when the process is opened from menu.

Steps:

1. Add a BP selector to created P&E
2. Select a single record and open the process
   -> OK: grid shows only records in the same org tree as the selected record
   -> OK: BP selector filters only those BPs in the same org tree as selected record
3. Select multiple records and open the process
   -> OK: grid shows records in the tree of all orgs current role has access to
   -> FAIL: BP selector filters records in the org tree of the last selected record, would expect to apply same criteria than grid
(0098792)
hgbot   
2017-09-04 10:01   
Repository: erp/devel/pi
Changeset: 1e69815c84cb4dc56743b7d5ee4837ae237b7258
Author: Inigo Sanchez <inigo.sanchez <at> openbravo.com>
Date: Fri Sep 01 14:15:27 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1e69815c84cb4dc56743b7d5ee4837ae237b7258 [^]

Related with the issue 36598: now selectors are working as expected in P&E

Selecting multiple records and opening the process with a selector in the 'P&E' it is
failing.

The problem has been fixed by take into account this case. Now when the selector is open
shows records in the tree of all orgs current role has access instead of records in the
org tree of the last selected record.

---
M modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
---
(0099103)
caristu   
2017-09-18 12:20   
Code reviewed + tested OK.
(0099350)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099353)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test