Hello Morvan,
It seems you are using an onchange, when really it should be a computed field.
See the documentation here: https://www.odoo.com/documentation/14.0/reference/orm.html#module-odoo.api
You need to define the compute value as a field parameter then use @api.depends("field1"). This would make the field readonly by default, meaning the cursor will not appear on the field2.
I believe this should fix your issue.
EDIT:
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!
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,