I added 2 columns in the sales order entry form. The 1st calculates the 2nd which can be possibly modified. My problem is that my cursor is positioned right away on the 2nd column, but the result appears only 1 to 2 seconds after.
I use onchange method to compute the field, is this the best way do that ?
I see 2 manners to obtain what i want :
- find a speeder way to get my result
- pause user interface until calculation is done (hourglass/gray screen)
Thank you in advance for any help you may offer.
Hello Morvan,
I have been looking further into this and I think I have found the solution!
Here is how you block the UI and I have tested a quick script with JQeury to run this with an Onchange event. Here is the code which was added to the back to make the event happen. This script was added to the Backend Assets.
<script type="text/javascript">
$(document).ready(function(){
$(document).on("change", "#o_field_input_27", function(){
$.blockUI();
setTimeout(function(){
$.unblockUI();
$("#o_field_input_28").focus();
}, 2000);
});
});
</script>
You need to find out the input id of the field and then call the blockUI funciton, set a delay of however long (2 seconds in this case) and then unblock the UI. You then find the next element, in your case the onchange field and set this as the new focus.
You can go further and only add this script depending on the model etc using t-if to not confuse with any other models.
Here is the documentation I have found relating to blocking the UI. http://malsup.com/jquery/block/#overview
Hope this solves the issue!
Thanks,