Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0031189Openbravo ERPA. Platformpublic2015-10-20 14:292016-01-25 19:02
malsasua 
inigosanchez 
highmajoralways
closedno change required 
20Community Appliance
 
 
alostale
Core
No
0031189: on change function is not working fine when the event is triggered by "TAB" key
in "on change" function, when the function recalculates one field value, if the event is triggered by the TAB key, the textualValue is wrong calculated. In the example attached (sample.txt), in the part of:

standardPrice: 14.285714285714286
standardPrice_textualValue: "11.43"

the correct value is 14.2857... and the textualValue is the old value.

If the function is triggered by mouse event, then it works fine:
standardPrice: 14.29
standardPrice_textualValue: "14.29"
Create a callout in client side (as attached file):
- Copy callout2 file at the end of ob-onchange-functions.js file.
- Login as "Openbravo Admin".
- Go to "Windows, Tabs and Fields" window and select "Price List" window.
- Select "Product Price" tab and go to "Field" subtab.
- Edit in form "Price Limit" field:
- Check "Displayed" and "Show in Grid View" checkbox for testing later.
- Also updated "On Change Function" field with following text: OB.OnChange.calcularpreciodia.
- Save the new configuration of "Price Limit" field.
- Logout and Compile.


- Login with "F&B Internation Admin Group".
- Go to "Price List" window and select "Tarifa de Ventas" record.
- Navigate to "Product price" subtab.
- Edit in grid any record and change "Unit Price" value to 2 and "List Price" value to 4.
- Change "Price Limit" value to 3 and change the focus with the mouse or TAB key. Note than "Unit Price" is changed to 4.
- Save the record and note than value in "Unit Price" is wrong because it is the old value.

NOTE: This issue can be reproduced in grid and form view. Also it can be reproduced with Mouse/Tab key event too.
No tags attached.
related to design defect 0031404 closed caristu setItemValue() function should be update "_textualValue" too 
related to defect 0031901 closed caristu decimal value can't be changed by trigger/observer after manual edition in form view 
txt sample.txt (1,113) 2015-10-20 14:29
https://issues.openbravo.com/file_download.php?file_id=8589&type=bug
txt callout.txt (159) 2015-10-22 08:31
https://issues.openbravo.com/file_download.php?file_id=8616&type=bug
txt callout2.txt (159) 2015-11-09 10:42
https://issues.openbravo.com/file_download.php?file_id=8703&type=bug
Issue History
2015-10-20 14:29malsasuaNew Issue
2015-10-20 14:29malsasuaAssigned To => platform
2015-10-20 14:29malsasuaFile Added: sample.txt
2015-10-20 14:29malsasuaModules => Core
2015-10-20 14:29malsasuaResolution time => 1447887600
2015-10-20 14:29malsasuaTriggers an Emergency Pack => No
2015-10-20 16:24malsasuaFile Added: function.txt
2015-10-20 16:25malsasuaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9739#r9739
2015-10-21 11:48alostaleStatusnew => scheduled
2015-10-21 11:48alostaleAssigned Toplatform => inigosanchez
2015-10-22 08:29malsasuaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9792#r9792
2015-10-22 08:30malsasuaFile Deleted: function.txt
2015-10-22 08:31malsasuaFile Added: callout.txt
2015-10-22 08:31malsasuaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9793#r9793
2015-11-09 10:39inigosanchezRelationship addedrelated to 0031404
2015-11-09 10:40inigosanchezSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=10103#r10103
2015-11-09 10:42inigosanchezFile Added: callout2.txt
2015-11-09 10:43inigosanchezReview Assigned To => alostale
2015-11-09 10:43inigosanchezNote Added: 0081613
2015-11-09 10:43inigosanchezStatusscheduled => closed
2015-11-09 10:43inigosanchezResolutionopen => no change required
2016-01-19 11:10alostaleRelationship addedrelated to 0031901
2016-01-25 19:02caristuNote Added: 0083596

Notes
(0081613)
inigosanchez   
2015-11-09 10:43   
First of all, note than the problem is reproduce with TAB key but also it is reproduced when the focus is changed with the mouse (click in another field). This problem was reproduced in grid and form view.

For update or recalculate one field value in "onChangeFunction" it is also necessary to update the "_textualValue" value. For this reason it is important to add this code to the "callout" that it was attached:

OB.OnChange.calcularpreciodia = function(item, view, form, grid) {
    var lp = form.getItem('listPrice');
    form.setItemValue('standardPrice', lp.getValue());
    form.setTextualValue('standardPrice', OB.Utilities.Number.OBPlainToOBMasked(lp.getValue(), lp.typeInstance.maskNumeric, lp.typeInstance.decSeparator, lp.typeInstance.groupSeparator, OB.Format.defaultGroupingSize), lp.typeInstance)
};

It has been resolved the problem with this new callout. It has been tested in grid/form and Tab/Mouse event. Also it has been created a new design defect to improve this issue. See related issue 31404.
(0083596)
caristu   
2016-01-25 19:02   
With the fix of 0031901 setTextualValue() is no longer needed to set values on client side callouts.